如何获取完整的URL地址

Eug*_*nov 8 c# asp.net-mvc asp.net-mvc-4

我想在ASp.NET MVC 4中获取完整的URL,例如用户输入的url:

http://localhost:5555/#globalName=MainLines&ItemId=5
Run Code Online (Sandbox Code Playgroud)

当我试图获得这个网址时Global.asax,我只会得到http://localhost:5555/

protected void Application_BeginRequest(object sender, EventArgs e)
{
    var url = HttpContext.Current.Request.Url;
}
Run Code Online (Sandbox Code Playgroud)

谢谢

Dar*_*rov 13

这不可能.片段(#)后面的部分永远不会在HTTP请求中发送到服务器,服务器无法检索它.片段只能通过javascript访问.因此,如果要在服务器上检索此值,则必须使用javascript读取它,然后将其存储在某个隐藏字段中,以便将其发送到服务器.