简体   繁体   中英

c# get iis rewrite url

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 ?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM