加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc-5 – Windows身份验证在ASP.NET MVC 5网络应用程序

发布时间:2020-12-15 22:21:59 所属栏目:asp.Net 来源:网络整理
导读:我有一个ASP.NET MVC 5应用程序,并尝试启用 Windows身份验证.开发机器是Windows Server 2008 R2,IIS Express 8.0,Visual Studio 2013 .NET Framework 4.5. 当我浏览应用程序时,我发现404未找到错误.该应用程序使用http:// localhost:63455 / Account / Log
我有一个ASP.NET MVC 5应用程序,并尝试启用 Windows身份验证.开发机器是Windows Server 2008 R2,IIS Express 8.0,Visual Studio 2013& .NET Framework 4.5.

当我浏览应用程序时,我发现404未找到错误.该应用程序使用http:// localhost:63455 / Account / Login?ReturnUrl = /进入重定向循环.最终,ReturnUrl最终变得非常大,因为它被附加到每个重定向.

我的web.config看起来像这样:

<system.web>
    <authentication mode="Windows"/>
  </system.web>

我已经尝试在开发服务器属性上设置匿名身份验证和Windows身份验证设置.

我也尝试添加以下appSettings:

<add key="autoFormsAuthentication" value="false"/>
<add key="enableSimpleMembership" value="false"/>

如何使Windows身份验证正常工作?

解决方法

Startup.Auth.cs中的ConfigureAuth方法包含以下需要为Windows身份验证删除的代码.

该代码用于使用OWIN进行表单验证.

// Enable the application to use a cookie to store information for the signed in user
        app.UseCookieAuthentication(new CookieAuthenticationOptions
        {
            AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,LoginPath = new PathString("/Account/Login")
        });
        // Use a cookie to temporarily store information about a user logging in with a third party login provider
        app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读