A potentially dangerous Request.Path value was detected from the client (*)

前端 未结 8 2090
执笔经年
执笔经年 2020-11-22 12:18

I am receiving the rather self explanatory error:

A potentially dangerous Request.Path value was detected from the client (*).

T

8条回答
  •  半阙折子戏
    2020-11-22 12:53

    The * character is not allowed in the path of the URL, but there is no problem using it in the query string:

    http://localhost:3286/Search/?q=test*
    

    It's not an encoding issue, the * character has no special meaning in an URL, so it doesn't matter if you URL encode it or not. You would need to encode it using a different scheme, and then decode it.

    For example using an arbitrary character as escape character:

    query = query.Replace("x", "xxx").Replace("y", "xxy").Replace("*", "xyy");
    

    And decoding:

    query = query.Replace("xyy", "*").Replace("xxy", "y").Replace("xxx", "x");
    

提交回复
热议问题