ASP MVC Url Encodes Double Escape Sequence

I want to encrypt part of the identifier of a given URL, and I used SHA-1 . This algorithm converts the identifier to the following line:

NxVhIhrfbZNzyxqtudUZdiv4DdQA9nF1Zn7CueGUiT8 = | h1bCRiN5zxexiIhHp + qNEQ0jVh / 8fMGiIkeTf30LVdU =

So my final url would be something like this:

http://localhost:9432/Product/Edit/NxVhIhrfbZNzyxqtudUZdiv4DdQA9nF1Zn7CueGUiT8=|h1bCRiN5zxexiIhHp+qNEQ0jVh/8fMGiIkeTf30LVdU=

This url has some character that causes the request to fail. For example, "+" is not allowed in the URL. Therefore, I used HttpUtility.UrlEncode()the encrypted Id and got this line as a result:

NxVhIhrfbZNzyxqtudUZdiv4DdQA9nF1Zn7CueGUiT8% 3D% 7ch1bCRiN5zxexiIhHp% 2bqNEQ0jVh% 2f8fMGiIkeTf30LVdU% 3d

Now my url:

http://localhost:9432/Product/Edit/NxVhIhrfbZNzyxqtudUZdiv4DdQA9nF1Zn7CueGUiT8%3d%7ch1bCRiN5zxexiIhHp%2bqNEQ0jVh%2f8fMGiIkeTf30LVdU%3d

However, using the above URL causes the following error:

escape-, -, escape-.

, web.config:

<system.webServer>
   <security>
      <requestFiltering allowDoubleEscaping="true" />
   </security>
</system.webServer>

:

  • HttpUtility.UrlEncode() - . , URL-?

  • , <requestFiltering allowDoubleEscaping="true" /> , , ?

+4
1

HttpUtility.UrlEncode() , +, IIS. IIS "+" URL-. :

<requestFiltering allowDoubleEscaping="true" />

, , , URL-.

, , IIS, , URL/User-Input, .

+1

Source: https://habr.com/ru/post/1683142/


All Articles