【问题标题】:How to allow double quotes in URL?如何在 URL 中允许双引号?
【发布时间】:2016-02-05 12:19:44
【问题描述】:

如何在 URL 中允许双引号我正在使用 URL 重写模块,但它否定了双引号

这里是 URL 重写规则

<match url="^([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-‘!@#$%^*()!~`\'?&quot;]+)"/>

【问题讨论】:

  • 提示:这个[&amp;quot;]可以匹配&amp;quot;

标签: asp.net regex url url-rewriting


【解决方案1】:

你根本不允许。它会将其读取为纯文本。当然不建议在 URL 中使用“”。如果您真的想使用它,请尝试使用:%22 而不是 "。

【讨论】:

    【解决方案2】:

    匹配双引号的另一种方法是使用十六进制表示:\x22\u0022

    <match url="^([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-‘!@#$%^*()!~`\'?\x22]+)"/>
                                                                       ^^^^
    

    <match url="^([_0-9a-z-]+)/([_0-9a-z-]+)/([_0-9a-z-‘!@#$%^*()!~`\'?\u0022]+)"/>
                                                                       ^^^^^^
    

    【讨论】:

      猜你喜欢
      • 2014-03-12
      • 2012-05-07
      • 1970-01-01
      • 2018-03-02
      • 1970-01-01
      • 2011-04-29
      • 2017-10-06
      • 1970-01-01
      相关资源
      最近更新 更多