HTTP 错误 404.15 - 未找到

Fra*_*ank 2 c# visual-studio iis-7.5 asp.net-mvc-4

请求过滤模块用于拒绝查询字符串过长的请求。

我遇到了上述错误,我几乎尝试了所有方法但没有运气

我的项目是 Visual Studio 2013 上的 MVC4

我确定的事情是正确的并尝试过。

  • 在我的课程中没有 [授权] Attr 与 [AllowAnonymous] Attr。
  • 我在我的配置文件中添加了 maxQueryStringLength="32768" maxUrlLength="65536"
  • 我已经添加-->
  • 我在我的控制器中登录 Actions 时有 [AllowAnonymous] attr。

  • 当我在 Visual Studio 上以调试模式或不使用调试模式运行应用程序时,我没有问题。

  • 这是我的路由配置 routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter 。可选的 } );

  • 这是我在 Web 服务器上遇到的错误

在此处输入图片说明

Sma*_*tis 5

正如错误消息告诉您的那样

请求过滤模块用于拒绝查询字符串过长的请求。

在屏幕截图中,您可以清楚地看到returnUrl参数很大。

所以有解决方案

  1. 清除returnUrl控制器方法中的参数[HttpPost] Login();

  2. 将以下内容添加到您的web.config:

网页配置

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxQueryString="*"/> <!-- Replace * with any number, which is required -->
    </requestFiltering>
  </security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)

在您的情况下,绝对使用解决方案 1。这只是您代码中的一个错误,无需接触 IIS 或其他配置文件即可轻松修复。

有关请求查询字符串限制的更多信息,请参阅此帖子


Sed*_*mcu 5

插入/更新 web.config 文件,如下面的示例

<configuration>
   <system.webServer>
       <security>
          <requestFiltering>
             <requestLimits maxQueryString="3000" maxUrl="1000" />
          </requestFiltering>
       </security>
   </system.webServer>
   <system.web>
       <httpRuntime maxQueryStringLength="32768" maxUrlLength="65536"/>
   </system.web>
</configuration>
Run Code Online (Sandbox Code Playgroud)