QueryString malformed after URLDecode

后端 未结 11 1435
太阳男子
太阳男子 2020-12-09 11:25

I\'m trying to pass in a Base64 string into a C#.Net web application via the QueryString. When the string arrives the \"+\" (plus) sign is being replaced by a space. It appe

11条回答
  •  萌比男神i
    2020-12-09 11:47

    I'm having this exact same issue except I have control over my URL. Even with Server.URLDecode and Server.URLEncode it doesn't convert it back to a + sign, even though my query string looks as follows:

    http://localhost/childapp/default.aspx?TokenID=0XU%2fKUTLau%2bnSWR7%2b5Z7DbZrhKZMyeqStyTPonw1OdI%3d
    

    When I perform the following.

    string tokenID = Server.UrlDecode(Request.QueryString["TokenID"]);
    

    it still does not convert the %2b back into a + sign. Instead I have to do the following:

    string tokenID = Server.UrlDecode(Request.QueryString["TokenID"]);
    tokenID = tokenID.Replace(" ", "+");
    

    Then it works correctly. Really odd.

提交回复
热议问题