在url路由时如何获取当前的物理URL?

时间:2014-08-14 06:59:36

标签: asp.net asp.net-mvc asp.net-webpages

我正在使用ASP.NET WebPages(而不是MVC)在我的Global.asax文件中路由Application_Start中的URL。

System.Web.Routing.RouteTable
    .Routes
    .MapWebPageRoute("", "~/Pages/Home.cshtml")
    .MapWebPageRoute("products", "~/Pages/Products.cshtml");

如何在发出请求时获取物理网址(MapWebPageRoute方法的第二个参数)?

protected void Application_BeginRequest(object sender, EventArgs e)
{
    // I want to be able to retrieve the .cshtml page url in this context
}

我尝试了Request.Url.AbsoluteUri.ToString(),但只给了我映射的网址。

0 个答案:

没有答案