如何在 .net 核心 webapi 中启用双重转义?

How to enable double escaping in .net core webapi?

我的 webapi 有问题。

所有命令都可以正常工作,直到地址中有 + 或 %2B。

当我尝试这样做时,我总是得到:

HTTP Error 404.11 - Not Found

我没有配置IIS的经验(我是绿色的),在项目中没有看到任何配置文件。

无法在路由中使用加号,这是 IIS 问题:

请看下面post:

double escape sequence inside a url : The request filtering module is configured to deny a request that contains a double escape sequence

您需要在 web.config 中添加以下部分:

<?xml version="1.0" encoding="utf-8"?>
<configuration> 
  <system.webServer>
    <security>
      <requestFiltering allowDoubleEscaping="true" />
    </security>
  </system.webServer>
</configuration>

结果:

注:

如果您在您的项目中没有web.config文件,您可以按照以下步骤创建它:

1.Right-单击您的项目->选择Add->选择New Item:

2.Search config 在搜索栏中->选择 Web Configuration File: