繁体   English   中英

HTTP错误401.0 - 未经授权的错误消息

[英]HTTP Error 401.0 - Unauthorized error message

我开发了一个简单的ASP.Net MVC 4应用程序,使用Windows身份验证在我们公司的本地网络上运行。 它在IIS上部署时工作正常。 但是,如果我通过Visual Studio运行应用程序,我会收到错误消息

HTTP错误401.0  - 未经授权

这是我的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>

对于调试,应用程序配置为使用“本地IIS Web服务器”运行,并在“应用程序”的“属性” - >“Web”选项卡中选中“使用IIS Express”选项。

事实证明,我必须在我的项目的Development Server属性中启用Windows Authentication ,禁用Anonymous Authentication

您需要添加到项目Web.config这:

<system.web>
    <authentication mode="Forms">
      <forms loginUrl="~/Account/Login" timeout="1" />
    </authentication>
  </system.web>

其中/ Account / Login是您从控制器登录的方法。

确保已启用目录浏览。

请参阅此链接以在IIS中添加用户。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM