1

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?

Anthon
  • 69,918
  • 32
  • 186
  • 246
Scott
  • 1,280
  • 4
  • 20
  • 35
  • possible duplicate of [How to know the original url after url rewrite?](http://stackoverflow.com/questions/3991552/how-to-know-the-original-url-after-url-rewrite) – Cyril Durand Jun 25 '15 at 10:21
  • 1
    thank you @CyrilDurand - that did indeed provide the answer i Need: HttpContext.Current.Request.RawUrl; – Scott Jul 15 '15 at 11:58

1 Answers1

0

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.

Kristi Jorgji
  • 1,154
  • 1
  • 14
  • 39