WAQ*_*WAQ 6 c# asp.net iis asp.net-mvc
我开发了一个简单的ASP.Net MVC 4应用程序,使用Windows身份验证在我们公司的本地网络上运行.它在IIS上部署时工作正常.但是,如果我通过Visual Studio运行应用程序,我会收到错误消息
这是我的Web.Config文件的样子
<system.web>
<authentication mode="Windows" />
<roleManager defaultProvider="WindowsProvider" enabled="true" cacheRolesInCookie="false">
<providers>
<add name="WindowsProvider" type="System.Web.Security.WindowsTokenRoleProvider" />
</providers>
</roleManager>
<compilation debug="true" targetFramework="4.5" />
<httpRuntime maxUrlLength="32767" maxQueryStringLength="32767" targetFramework="4.5" />
</system.web>
<system.webServer>
<modules>
<!--<remove name="FormsAuthenticationModule" />-->
</modules>
<security>
<requestFiltering>
<requestLimits maxUrl="32767" maxQueryString="32767" />
</requestFiltering>
</security>
Run Code Online (Sandbox Code Playgroud)
对于调试,应用程序配置为使用"本地IIS Web服务器"运行,并在"应用程序"的"属性" - >"Web"选项卡中选中"使用IIS Express"选项.
事实证明,我必须在我的项目的属性中启用Windows Authentication、禁用。Anonymous AuthenticationDevelopment Server
小智 6
您需要将以下内容添加到项目 Web.config 中:
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="1" />
</authentication>
</system.web>
Run Code Online (Sandbox Code Playgroud)
其中 /Account/Login 是控制器的登录方法。