【问题标题】:ASP.NET, IIS 6 and url rewritingASP.NET、IIS 6 和 url 重写
【发布时间】:2011-02-12 11:39:35
【问题描述】:

我在一个带有 IIS 6 的 Windows 主机上购买了一个共享主机。

我想知道如何重写 url。

我无法修改服务器上的任何内容,我唯一能做的就是使用...我的 asp.net 代码! 一些忠告 ?

谢谢!

【问题讨论】:

标签: asp.net iis-6 url-rewriting


【解决方案1】:

正如 ScottGu 博客所建议的,您可以

1.使用 ASP.NET 提供的HttpContext.RewritePath() 方法手动重写

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。使用 HttpModule
使用HttpModule(例如urlrewriter.net)不需要对服务器进行任何更改,只需对Web.Config 进行一些更改并部署模块DLL

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-04-07
    • 1970-01-01
    • 1970-01-01
    • 2011-12-04
    • 2012-07-03
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多