开发者

Url fragment is empty

Using ASP.NET MVC3, the 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 />

ret开发者_运维问答urns:

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 fragment always empty? I need to be able to parse this info on the server side.


The fragment (everything after the # in a url) doesn't get passed to the server. So the Fragment property will always be empty when you attempt to get it from a request.

The Fragment property is typically only used when constructing URLs.

There's no easy way to get the fragment on the server. Typically you would have to use javascript to retrieve the fragment.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜