HTTP Error 401.0 - Error Message

I developed a simple ASP.Net MVC 4 application using Windows authentication to work on our company’s local network. It works great when deployed to IIS. But if I run the application through Visual studio, I get an error

HTTP Error 401.0 - Unauthorized

This is what my Web.Config file looks like

<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>

For debugging, the application is configured to run using the "Local IIS Web Server" with the option "Use IIS Express", noted in the Application Properties → Web tab.

+4
source share
3 answers

, Windows Authentication, Anonymous Authentication Development Server .

+2

, .

. IIS.

0

You need to add the following to your Web.config project:

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

Where / Account / Login is your login from the controller.

0
source

Source: https://habr.com/ru/post/1668162/


All Articles