ASP.NET, IIS 6 and url rewriting
i've bought a shared hosting on a windows hoster with IIS 6.
I would like to know how to rewrite url.
I can't modify anything on t开发者_开发百科he server, the only thing i can do is to use ... my asp.net code ! some advice ?
Thanks!
As the ScottGu blog suggests, you can
1. Do the rewrite manually using the HttpContext.RewritePath()
method that ASP.NET provides
void Application_BeginRequest(object sender, EventArgs e) {
string fullOrigionalpath = Request.Url.ToString();
if (fullOrigionalpath.Contains("/Products/Books.aspx")) {
Context.RewritePath("/Products.aspx?Category=Books");
}
else if (fullOrigionalpath.Contains("/Products/DVDs.aspx")) {
Context.RewritePath("/Products.aspx?Category=DVDs");
}
}
2. Use a HttpModule
Using a HttpModule
(such as urlrewriter.net) does not require any changes on the server, only some changes on Web.Config
and deploying the module DLLs
精彩评论