I know on client side (javascript) you can use windows.location.hash but could not find anyway to access from the server side.
相关问题
- Carriage Return (ASCII chr 13) is missing from tex
- How to store image outside of the website's ro
- 'System.Threading.ThreadAbortException' in
- Request.PathInfo issues and XSS attacks
- How to dynamically load partial view Via jquery aj
相关文章
- asp.net HiddenField控件扩展问题
- asp.net HiddenField控件扩展问题
- Asp.Net网站无法写入错误日志,测试站点可以,正是站点不行
- asp.net mvc 重定向到vue hash字符串丢失
- FormsAuthenticationTicket expires too soon
- “Dynamic operations can only be performed in homog
- What is the best way to create a lock from a web a
- Add to htmlAttributes for custom ActionLink helper
RFC 2396 section 4.1:
(emphasis added)
Probably the only choice is to read it on the client side and transfer it manually to the server (GET/POST/AJAX). Regards Artur
You may see also how to play with back button and browser history at Malcan
Possible solution for GET requests:
New Link format:
http://example.com/yourDirectory?hash=video01
Call this function toward top of controller or
http://example.com/yourDirectory/index.php
:We had a situation where we needed to persist the URL hash across ASP.Net post backs. As the browser does not send the hash to the server by default, the only way to do it is to use some Javascript:
When the form submits, grab the hash (
window.location.hash
) and store it in a server-side hidden input field Put this in a DIV with an id of "urlhash
" so we can find it easily later.On the server you can use this value if you need to do something with it. You can even change it if you need to.
On page load on the client, check the value of this this hidden field. You will want to find it by the DIV it is contained in as the auto-generated ID won't be known. Yes, you could do some trickery here with .ClientID but we found it simpler to just use the wrapper DIV as it allows all this Javascript to live in an external file and be used in a generic fashion.
If the hidden input field has a valid value, set that as the URL hash (
window.location.hash again
) and/or perform other actions.We used jQuery to simplify the selecting of the field, etc ... all in all it ends up being a few jQuery calls, one to save the value, and another to restore it.
Before submit:
On page load:
IsHashValid()
can check for "undefined
" or other things you don't want to handle.Also, make sure you use
$(document).ready()
appropriately, of course.That's because the browser doesn't transmit that part to the server, sorry.
Just to rule out the possibility you aren't actually trying to see the fragment on a GET/POST and actually want to know how to access that part of a URI object you have within your server-side code, it is under Uri.Fragment (MSDN docs).