2015-07-06 32 views
1

我在我的web表單中使用路由。例如:如何從asp.net中獲取原始網址?

routes.MapPageRoute("Home", "HomePage", "~/Default.aspx"); 

,我重定向到頁面

Response.RedirectToRoute("Home"); 

現在有一個函數(或解決方案)在asp.net,這將使它路由名稱[首頁](或URL參數[ HomePage])並返回原始地址(Default.aspx)?

非常感謝。

回答

0

你可以只獲取完整URL:

HttpContext.Current.Request.Url.AbsoluteUri; 

和看其他的.url性能

看到這個答案更多的例子:How to get the URL of the current page in C#

+0

謝謝回答。其他問題,但是,類似於上一個問題:是否有一個函數會給它的URL參數(HomePage)和返回路由名稱?謝謝。 –

+0

好的。我找到我的答案在http://stackoverflow.com/questions/721392/asp-net-system-web-routing-find-actual-aspx-page 我的答案是Page.AppRelativeVirtualPath; –