Context.Request.RawUrl returns an invalid partially encoded URL, how can I fix it?

Since I decided to pass the identifier of a specific record along the query line, so that I encrypt the identifier ( id=090ed4fe-daec-452d-b025-f664dcc1164d) and bind it to the URL.

As we all know, URL-encoded value for / is% 2f. Thus, on a specific application instance, the id ( id=090ed4fe-daec-452d-b025-f664dcc1164d) value , which was encrypted and then encoded, returns the value:

M2vaIbPkOqO6lw4jv%2bqE2f%2fhTrK495ny92uPcLBOJBNcMpg1RUme%2fvAo6LyKfdp9e

When I follow the link, I get:

M2vaIbPkOqO6lw4jv+qE//hTrK495ny92uPcLBOJBNcMpg1RUme/vAo6LyKfdp9e

for the "encrypted and encoded" part, which is correct. But when I use the property Context.Request.RawUrlto get the url, I get:

M2vaIbPkOqO6lw4jv+qE/hTrK495ny92uPcLBOJBNcMpg1RUme/vAo6LyKfdp9e

, , (1) '/' , , .

, , . , (2) '/' (2f% 2f), .

, Context.Request.RawUrl (1) '/'?

+3
1

, URL, - . "Remvoing duplicate slashes". * , %2bqE2f%2f, % 2f. ?

, ( ), , ?

WebForm1.aspx( // ):

<a href="WebForm1.aspx?id=M2vaIbPkOqO6lw4jv+qE//hTrK495ny92uPcLBOJBNcMpg1RUme/vAo6LyKfdp9e">Click!</a>
<a href="WebForm1.aspx?id=M2vaIbPkOqO6lw4jv%2bqE%2f%2fhTrK495ny92uPcLBOJBNcMpg1RUme%2fvAo6LyKfdp9e">Click Encoded!</a>
<br />
<br />
<asp:Label runat="server" ID="myLabel">
</asp:Label>

WebForm1.aspx.cs:

protected void Page_Load(object sender, EventArgs e)
{
    myLabel.Text = "<pre>" + Request.RawUrl + "</pre>";
}
0

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


All Articles