【问题标题】:Why is '*' an invalid Request.Path character?为什么 '*' 是一个无效的 Request.Path 字符?
【发布时间】:2017-04-24 07:42:29
【问题描述】:

我无法搜索/找到此问题的答案。请帮我理解。

背景: 我正在添加一个新的rest-api,它将版本(1.0.1)作为字符串格式的输入并相应地返回资源。 我想知道 1.* 也是一个有效的输入版本值,用户说我不知道​​ 1.* 中的最新版本,只要主要版本是 1,任何最新的次要/补丁版本都可以。

【问题讨论】:

    标签: asp.net rest asp.net-web-api


    【解决方案1】:

    实际上 * 应该是 URL 中的安全字符 .... 看看下面的链接

    https://perishablepress.com/stop-using-unsafe-characters-in-urls/

    尝试对其进行编码..

    将“*”替换为“%2A”或使用 URL 编码实用程序函数

    https://msdn.microsoft.com/en-us/library/4fkewx0t(v=vs.110).aspx

    【讨论】:

    • 编码也无济于事。我得到以下异常:
      [HttpException (0x80004005): 从客户端检测到潜在危险的 Request.Path 值 (*)。] System.Web.HttpRequest.ValidateInputIfRequiredByConfig() +9903832 System.Web.PipelineStepManager.ValidateHelper( HttpContext 上下文)+53
    猜你喜欢
    • 2010-10-18
    • 2015-11-16
    • 1970-01-01
    • 2023-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-17
    • 1970-01-01
    相关资源
    最近更新 更多