【问题标题】:allowDoubleEscaping on .net core 2.0.net core 2.0 上的 allowDoubleEscaping
【发布时间】:2019-06-12 12:40:33
【问题描述】:

我正在使用 asp.net 身份,GenerateEmailConfirmationTokenAsync 给了我一个用于电子邮件确认的令牌。我不能在确认网址中使用此代码,因为它会出错:

请求过滤模块被配置为拒绝包含双转义序列的请求。

该问题的解决方案是在 web.config 中允许DoubleEscaping,但我如何在 appsettings.json 中做到这一点?我应该在 appsettings 或 Startup.cs 中以某种方式编写此代码:

<system.webServer>
    <security>
        <requestFiltering allowDoubleEscaping="true"/>
    </security>
</system.webServer>

【问题讨论】:

  • 我也遇到了这个问题。 MS 拥有创建包含此类错误的确认令牌的功能是多么令人沮丧。
  • 你有没有想过这个问题?

标签: asp.net-core asp.net-core-2.0 appsettings asp.net-core-identity


【解决方案1】:

如果您在 IIS 中运行,它仍然是一个 IIS 设置。

使用以下内容创建一个web.Release.config 文件(您的实际项目中不需要web.config 文件):

<?xml version="1.0"?>
<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <location>
    <system.webServer>

      <security xdt:Transform="InsertIfMissing">
        <requestFiltering allowDoubleEscaping="true" />
      </security>

    </system.webServer>
  </location>
</configuration>

当您发布发布版本时,这将被添加。包含InsertIfMissing 部分非常重要,否则它将被忽略。

您不需要第三方软件包,例如 this。 7

另见https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/iis/transform-webconfig?view=aspnetcore-3.1

【讨论】:

    猜你喜欢
    • 2018-01-22
    • 1970-01-01
    • 2018-11-20
    • 2018-10-12
    • 2018-06-08
    • 1970-01-01
    • 2018-09-14
    • 2017-12-30
    • 2018-08-03
    相关资源
    最近更新 更多