I have a web app deployed that uses windows authorization. It works OK, but when I copied it locally, I was getting an Error 401.2 (Access Denied). My user is already authorized and can access the deployed version but not the local one. I need to have a working local version because it is a better practice to develop on the local machine and deploy rather than develop on the server machine.

Web.config extract below...

<?xml version="1.0"?>

<configuration>
  <connectionStrings>
    <!--Connection strings here-->
  </connectionStrings>
  <system.web>
    <compilation debug="true">
      <assemblies>
    <!--Assemblies here-->
      </assemblies>
    </compilation>
    <authentication mode="Windows"/>
    <identity impersonate="false"/>
    <customErrors mode="Off"/>
    <authorization>
      <deny users="?"/>
    </authorization>
    <roleManager enabled="true" cacheRolesInCookie="true" defaultProvider="AspNetWindowsTokenRoleProvider"/>
  </system.web>
  <system.webServer>
    <directoryBrowse enabled="true"/>
    <defaultDocument>
      <files>
        <add value="Home.aspx"/>
      </files>
    </defaultDocument>
    <httpRedirect enabled="false" destination="http://report.com/"/>
  </system.webServer>
  <location path="Functions/AdminConfiguration.aspx">
    <system.web>
      <authorization>
        <allow roles="DataTeam"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="Functions/BusinessAccountReportConfig.aspx">
    <system.web>
      <authorization>
        <allow roles="DataTeam"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="Functions/BusinessAccountRebateConfiguration.aspx">
    <system.web>
      <authorization>
        <allow roles="DataTeam"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="Functions/Watchlists.aspx">
    <system.web>
      <authorization>
        <allow roles="DataTeam,Finance"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="Functions/MappingTablesConfiguration.aspx">
    <system.web>
      <authorization>
        <allow roles="DataTeam"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="Functions/Transactions.aspx">
    <system.web>
      <authorization>
        <allow roles="DataTeam"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="Functions/Administration.aspx">
    <system.web>
      <authorization>
        <allow roles="DataTeam"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <location path="Functions/IPSReports.aspx">
    <system.web>
      <authorization>
        <allow roles="DataTeam"/>
        <deny users="*"/>
      </authorization>
    </system.web>
  </location>
  <appSettings>
  </appSettings>
</configuration>
有帮助吗?

解决方案

You need to enable Windows Authentication in Visual Studio. To do this, make sure your project is active in the solution explorer, then click on properties. You will need to enable windows authentication and then disable anonymous authentication. And that should do it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top