asp.net-mvc HTTP 错误 404.15 - 未找到 ...因为查询字符串太长
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/28483745/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
HTTP Error 404.15 - Not Found ...because the query string is too long
提问by Rob Bowman
I've checked lots of posts about this error but not been able to fix the problem yet.
我已经检查了很多关于这个错误的帖子,但还没有解决这个问题。
I have simple MVC5 website built in VS2013 running on Windows 8 pro. When the site was created the option for individual accounts was selected. I now need to enable windows authentication so that only AD account users can use the website and also authorisation so that I can limit access to certain views / controllers to particular AD groups.
我有一个在 Windows 8 专业版上运行的 VS2013 中内置的简单 MVC5 网站。创建站点时,选择了个人帐户选项。我现在需要启用 Windows 身份验证,以便只有 AD 帐户用户可以使用该网站并进行授权,以便我可以将某些视图/控制器的访问权限限制为特定的 AD 组。
Having selected the web project within VS I have updated the properties window (F4) so that Anonymous Authentication is set to disabled and Windows Authentication is set to Enabled.
在 VS 中选择了 Web 项目后,我更新了属性窗口 (F4),以便将匿名身份验证设置为禁用,并将 Windows 身份验证设置为启用。
The web.config for the project now contains the following sections:
项目的 web.config 现在包含以下部分:
<system.web>
<authentication mode="Windows" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<authorization>
<deny users="?" />
</authorization>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
</system.webServer>
I access the site from IIS or F5 I get the error: HTTP Error 404.15 - Not Found The request filtering module is configured to deny a request where the query string is too long. I notice that something has looped to give a ReturnUrl which is a repeating long concatenation within the query string.
我从 IIS 或 F5 访问站点我收到错误:HTTP 错误 404.15 - 未找到请求过滤模块被配置为拒绝查询字符串太长的请求。我注意到有些东西循环给出了一个 ReturnUrl,它是查询字符串中的重复长连接。
Within the IIS\Authentication section, I have set to disabled "Anonymous Authentication, ASP.Net Impersonisation, and Forms Authentication". Within the section IIS.Net Authorization Rules I have set to Deny "Anonymous Users" and Allow "All Users"
在 IIS\Authentication 部分中,我已设置为禁用“匿名身份验证、ASP.Net Impersonisation 和表单身份验证”。在 IIS.Net 授权规则部分中,我已设置为拒绝“匿名用户”并允许“所有用户”
Where am I going wrong?
我哪里错了?
回答by Chris Pratt
The only time I've personally run into this issue is when I accidentally added [Authorize]to a child action that was used in the layout. Adding [Authorize]to your sign in action would have the same effect or simply neglecting to add [AllowAnonymous]on your sign in action, when the controller it is in has [Authorize]on it. Long and short, this is being caused by something requiring authorization on the actual sign in page, which then causes you to be redirected to the sign in page, which needs authorization, causing you to be redirected to the sign in page, etc.
我个人遇到这个问题的唯一一次是当我不小心添加[Authorize]到布局中使用的子操作时。添加[Authorize]到您的登录操作将具有相同的效果,或者只是忽略添加[AllowAnonymous]您的登录操作,当它所在的控制器已[Authorize]在其上时。总而言之,这是由需要在实际登录页面上授权的内容引起的,然后导致您被重定向到登录页面,该页面需要授权,导致您被重定向到登录页面等。
tl;dr
tl;博士
- Make sure your sign in / login action does nothave
[Authorize]. - Make sure your sign in / login action doeshave
[AllowAnonymous]. - Make sure no child actions used in your layout or sign in page have
[Authorize]or have[AllowAnonymous]if they are in a controller decorated with[Authorize].
- 确保您在/ login动作标志不具备
[Authorize]。 - 确保您的登录/登录操作确实具有
[AllowAnonymous]. - 确保在您的布局或登录页面中使用的子操作没有
[Authorize]或有,[AllowAnonymous]如果它们在用 装饰的控制器中[Authorize]。
回答by Rakesh Karthik
I got this error when I enabled Windows authentication. I wanted to authorize the user based on Windows login and I do not want login page in my application.
启用 Windows 身份验证时出现此错误。我想根据 Windows 登录授权用户,我不想在我的应用程序中使用登录页面。
I got the error fixed by adding the below in my Web config file.
我通过在我的 Web 配置文件中添加以下内容来修复错误。
Under the tag
system.web, changed authenticationmode="None"to authenticationmode="Windows"Under tag
appSettings, added addkey="owin:AutomaticAppStartup" value="false"
在标记下
system.web,将身份mode="None"验证更改为身份验证mode="Windows"在 tag 下
appSettings,添加了 addkey="owin:AutomaticAppStartup" value="false"
回答by Mahmoud
You may have a function in startup that redirects you to a login page. You must disable it.
您可能在启动时有一个功能可以将您重定向到登录页面。您必须禁用它。
I created the project by default authentication method which creates an account controller and its dependencies. When I changed the authentication method to Windows, the mentioned error was raised.
我通过默认身份验证方法创建了该项目,该方法创建了一个帐户控制器及其依赖项。当我将身份验证方法更改为 Windows 时,出现了上述错误。
What I did was comment out the ConfigureAuth(app)function in my Startup.cs file to resolve the issue.
我所做的是注释掉ConfigureAuth(app)Startup.cs 文件中的函数来解决这个问题。
回答by Diego
I had the same problem..
我有同样的问题..
Check under Project Properties..
在项目属性下检查..
Anonymous Authentication=False
Windwos Authentication=True
回答by salli
We ran into a similar issue and our authorize filters were correctly implemented. I am leaving this here in case someone else runs into same problem with IIS 10.
我们遇到了类似的问题,我们的授权过滤器已正确实施。如果其他人在 IIS 10 中遇到同样的问题,我将把它留在这里。
After working with Microsoft support, we determined that the .Net Authorization Rule was not enabled on the server level.
在与 Microsoft 支持人员合作后,我们确定未在服务器级别启用 .Net 授权规则。


