Cia*_*ian 4 c# asp.net authentication asp.net-mvc asp.net-mvc-4
我使用Visual Studio 2015创建了一个MVC Web应用程序.我的目标是根据需要将身份验证模式从none更改为Windows身份验证,以便我可以使用@ User.Identity.Name方法来识别用户.到目前为止我尝试过的简短摘要:
<authentication mode="Windows"/>的内<system.web>标签添加system.webServer标记(每当我添加它时,它都会在ERR_TOO_MANY_REDIRECTS中结束):
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxUrl="10999" maxQueryString="2097151" />
</requestFiltering>
</security>
</system.webServer>
Run Code Online (Sandbox Code Playgroud)我尝试从头开始创建一个新项目,并在项目设置期间整齐地选择Windows身份验证.这工作正常,所以我相信我的IISExpress设置是100%正确.我甚至检查了applicationhost.config文件,它没有我的特定项目的条目.再次,如果我在创建新项目时选择正确的身份验证,它的工作正常.
当我尝试运行Visual Studio项目时,上述所有内容似乎都不起作用并且最终都出现IIS错误:
HTTP Error 404.15 - Not Found
The request filtering module is configured to deny a request where the query string is too long.
Run Code Online (Sandbox Code Playgroud)
这是IIS错误页面中的URL:
你可以告诉我得到一个无限的重定向循环,这可能就是我无法让它工作的原因.但我确实不知道是什么导致了它.任何帮助是极大的赞赏.
猜猜我能够回答我自己的问题,因为我刚刚开始工作.对于将来遇到类似错误的人来说,可能会派上用场.
解决方案:我必须在App_Start/Startup.Auth.cs中注释掉以下代码:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1198 次 |
| 最近记录: |