开发者

ASP.NET, IIS 6 and url rewriting

开发者 https://www.devze.com 2022-12-28 10:01 出处:网络
i\'ve bought a shared hosting on a windows hoster with IIS 6. I would like to know how to rewrite url.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号