How to stop IIS from decoding URL

asp.net, iis, url, url-routing

Solution

Take a look into Rewrite Module.

some information here: PRESERVING ORIGINAL URL

The URL Rewrite Module preserves the original requested URL path in the following server variables:

HTTP_X_ORIGINAL_URL – this server variable contains the original URL in decoded format; UNENCODED_URL – this server variable contains the original URL exactly as it was requested by a Web client, with all original encoding preserved.

hope that helps.

Problem

I use windows 7, IIS 7.5, .NET 4.5. (For windows 8, IIS 8.5, .NET 4.5, this works). performing a GET request with URL: ``` http://my.host/api1/MyEntity('%2311282') ``` Problem is that when it gets to servers side code the %23 char is already decoded to '#' and Uri object thinks it is a fragment char. Win8 machine receives the url with char %23 untouched. Tried to: 1) use this config setting ``` <httpRuntime targetFramework="4.5" relaxedUrlToFileSystemMapping="true" /> ``` 2) add '/' in the end of the URL ``` http://my.host/api1/MyEntity('%2311282')/ ``` 3) uninstall the url rewrite 2 module - and reinstall it. also tried to comment the rewrite section in web.config for the module. Why I want to replicate windows 8 behavior - not decoding the URL. Any ideas?

Original source

Related problems