2012-07-13 73 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中試過這段代碼。這個對我有用!