ASP.NET, IIS 6 and url rewriting

牧云@^-^@ 提交于 2019-12-24 07:39:21

问题


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 the server, the only thing i can do is to use ... my asp.net code ! some advice ?

Thanks!


回答1:


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



来源:https://stackoverflow.com/questions/2714974/asp-net-iis-6-and-url-rewriting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!