我正在使用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(),但只给了我映射的网址。