2015-07-06 36 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; –