1
votes

I am using iis rewrite 2.0

URLs like this http://www.mywebsite.com/index.aspx?article=1234
becomes http://www.mywebsite.com/article/1234

In the C# I want to obtain this friendly URL, when I use

HttpContext.Current.Request.Url.AbsoluteUri

I get: http://www.mywebsite.com/index.aspx?article=1234

How do I get the friendly URL in my C#: http://www.mywebsite.com/article/1234?

1
thank you @CyrilDurand - that did indeed provide the answer i Need: HttpContext.Current.Request.RawUrl;Scott

1 Answers

-1
votes

You have to use Request.RawUrl instead of Request.Url. Request.RawUrl gives the original url that the user entered. Request.Url gives the url after being changed by the web server or aspnet routes.