Fra*_*ank 2 c# visual-studio iis-7.5 asp.net-mvc-4
请求过滤模块用于拒绝查询字符串过长的请求。
我遇到了上述错误,我几乎尝试了所有方法但没有运气
我的项目是 Visual Studio 2013 上的 MVC4
我确定的事情是正确的并尝试过。
我在我的控制器中登录 Actions 时有 [AllowAnonymous] attr。
当我在 Visual Studio 上以调试模式或不使用调试模式运行应用程序时,我没有问题。
这是我的路由配置 routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller = "Home", action = "Index", id = UrlParameter 。可选的 } );
这是我在 Web 服务器上遇到的错误
正如错误消息告诉您的那样
请求过滤模块用于拒绝查询字符串过长的请求。
在屏幕截图中,您可以清楚地看到returnUrl参数很大。
所以有解决方案
清除returnUrl控制器方法中的参数[HttpPost] Login();
将以下内容添加到您的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 或其他配置文件即可轻松修复。
有关请求查询字符串限制的更多信息,请参阅此帖子。
插入/更新 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)