2012-07-13 74 views
-1

我正在ASP.NET网站(VS 2010,Framework 4.0)上工作。使用C#重写URL#

如何使用C#重写页面的URL?有没有第三方工具可用?谁可以帮我这个事?

+1

[检查](http://msdn.microsoft.com/en-us/library/ms972974.aspx) – HariHaran 2012-07-13 12:16:01

+1

从whathaveyoutried.com没有运气 – Bisileesh 2012-07-13 12:24:21

+0

我不想在web.config中重新写入URL。 – Bisileesh 2012-07-13 12:25:58

回答

1
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中试过这段代码。这个对我有用!