How to get current page Url in MVC
I am writing a web app that has to deal with urls containing hash character ("#"). I am using MVC 1 with ASP.NET 3.5 (VS 2008). My urls are like this one:
www.mysite.com/token/?name1=value1&#&name2=value2
My issue is that I cannot find a method to get the original URL, but only get the substring before the hash character:
www.mysite.com/token/?name1=value1&
I used 开发者_开发百科the MVC methods provided from the class HttpRequestBase
.
Anyone can suggest me an alternate method to get the entire url? Thank you, this is my very first question!
PS: I think maybe I have to encode my hash character, isn'it?
You cannot access anything after the # from the server-side - this is all Client-side. You will need to find another way to pass the information you want through to the server.
If you are posting, you can do this with hidden fields. If you are using ajax posts, you can pass the data within the model.
精彩评论