Url fragment is empty

Using ASP.NET MVC3, url http://localhost:22713/tests#123456 with the following code:

 Your user agent: @Request.UserAgent<br /> Url: @Request.Url.AbsoluteUri<br /> Url fragment: @Request.Url.Fragment<br /> 

returns:

 Your user agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16 Url: http://localhost:22713/tests Url fragment: 

Why is the fragment always empty? I need to analyze this information on the server side.

+6
asp.net-mvc-3
source share
1 answer

The fragment (everything after # in the URL) is not transmitted to the server. That way, the Fragment property will always be empty when you try to get it from the request.

The Fragment property is usually used only when constructing URLs.

There is no easy way to get the fragment on the server. Generally, you will need to use javascript to extract the fragment.

+10
source share

All Articles