C# 使用C重新写入URL#

C# 使用C重新写入URL#,c#,asp.net,url-rewriting,C#,Asp.net,Url Rewriting,我在ASP.NET网站上工作(VS2010,框架4.0) 如何使用C#重写页面的URL?是否有任何第三方工具可用?有人能帮我吗?如果您使用的是IIS 7.x,您最好使用URL重写模块2.0,从这里开始: 上面的链接指向IIS6时代使用的“旧”技术 iis7.x的新选项更简单、更方便 void Application_BeginRequest(object sender, EventArgs e) { // Get the current path string CurrentUR

我在ASP.NET网站上工作(VS2010,框架4.0)


如何使用C#重写页面的URL?是否有任何第三方工具可用?有人能帮我吗?

如果您使用的是IIS 7.x,您最好使用URL重写模块2.0,从这里开始:

上面的链接指向IIS6时代使用的“旧”技术

iis7.x的新选项更简单、更方便

void Application_BeginRequest(object sender, EventArgs e)
{
    // Get the current path
    string CurrentURL = Request.Url.ToString();
     // Condition
    if (CurrentURL.Contains("HtmlResponce.aspx"))
    {
        HttpContext MyContext = HttpContext.Current;

        // Re write here
        MyContext.RewritePath("testPage.aspx");
    }
}

我在Global.asax中尝试了这段代码。这对我有用

[检查]()whathaveyoutried.com没有运气我没有尝试在web.config中重新写入URL。