Razor is just HTML with a bit of C# mixed in, so you should be able to get it in the normal way that you would in C#:
@Request.Url.ToString()
Edit: Hmm, I didn't read properly, seems like you already tried something similar. What rewriter are you using? Umbraco's?? Try @HttpContext.Current.Request.Path as well.
According to this post, using Request.Url should give you the rewritten URL. Are you using the 2.0 version of the URL Rewrite module for IIS? It's much improved over the original version.
access user friendly url in razor
hello....
I want to access current url which is re-written using user-friendly url rules....
By using following line it shows url with querystring params, i.e. http://mydomain.com/default/?id=2
String url = Request.Url.AbsoluteUri;
But I need like.... http://mydomain.com/default/2/ ; ... how can I get thje url which is displayed in addressbar of browser?
Razor is just HTML with a bit of C# mixed in, so you should be able to get it in the normal way that you would in C#:
@Request.Url.ToString()
Edit: Hmm, I didn't read properly, seems like you already tried something similar. What rewriter are you using? Umbraco's?? Try @HttpContext.Current.Request.Path as well.
I tried your suggestion but does not give what I need. I have used IIS manager for re-write and redirect user-friendly url. ....
so say mu url appears as http://mydomain.com/books/education/ ; where education is book category i.e. category is parameter. I want to access http://mydomain.com/books/education/ and not http://mydomain.com/books/?category=education. ; How to achieve this?
OR how can use javascript in razor to access address bar url exactly as it is?
According to this post, using Request.Url should give you the rewritten URL. Are you using the 2.0 version of the URL Rewrite module for IIS? It's much improved over the original version.
hey I solved the problem... using following...
"http://" +HttpContext.Current.Request.ServerVariables["HTTP_HOST"]) + Request.RawUrl;
is working on a reply...