c# - Url rewriting in asp.net 3.5 with multiple querystring -
i have travel related web application in url looks
mytravel/tour/inner.aspx?pid=2&cid=8
and
mytravel/tour/inner.aspx?pid=2&cid=8&deptf=nd
now want url rewriting on application
mytravel/tour/goa/new-year-goa
here goa , new year goa fetched pid , cid values.
help me.
thanks in advance
[edit: reformation]
url rewriting can done follows,
void application_beginrequest(object sender, eventargs e) { string fullorigionalpath = request.url.tostring(); if (fullorigionalpath.contains("/tour/inner.aspx?pid=2&cid=8")) { context.rewritepath("/tour/goa/new-year-goa"); } else if (fullorigionalpath.contains("/tour/inner.aspx?pid=2&cid=8&deptf=nd")) { context.rewritepath("/tour/goa/new-year-goa"); //this can else according requirements. } }
you can @ http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx
or else can modify web.config
achieve goal,
here sample,
<?xml version="1.0"?> <configuration> <configsections> <section name="rewriter" requirepermission="false" type="intelligencia.urlrewriter.configuration.rewriterconfigurationsectionhandler, intelligencia.urlrewriter" /> </configsections> <system.web> <httpmodules> <add name="urlrewriter" type="intelligencia.urlrewriter.rewriterhttpmodule, intelligencia.urlrewriter"/> </httpmodules> </system.web> <rewriter> <rewrite url="~/tour/inner.aspx?pid=2&cid=8" to="~/tour/goa/new-year-goa" /> //some other re-writers achieve specific requirements. </rewriter> </configuration>
[edit: following can 1 solution]
ok. saying need check pid
, cid
redirect accordingly,
one way achieve below,
request.querystring("pid")
,request.querystring("cid")
- store them variables,
- check variables switch...case mechanism , according passed condition set path using
context.rewritepath("your specified path")
the other way using database,
- create table containing 3 columns,
pid
,cid
, ,location_path
- now
cid
,pid
using above mentionedrequest.querystring
- using sql query, select location table matchs
cid
,pid
fetchedrequest.querystring
, set using context.rewritepath
hopefully clear now.
hope helps.
Comments
Post a Comment