在IIS中禁用匿名身份验证导致错误404.15

问题描述 投票:-2回答:2

作为标题,我想在IIS服务器中为我的ASP.NET Boilerplate网站(MVC)禁用Anonymous Authentication,而是使用Form Authentication。是否可以这样做,因为如果我禁用Anonymous Authentication,我的网站会导致错误“HTTP错误404.15 - 未找到”

更新1:这是我的web.config

<system.web>
    <globalization culture="auto" uiCulture="auto" />
    <compilation debug="true" targetFramework="4.6.1">
      <assemblies>
        <add assembly="System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
      </assemblies>
    </compilation>
    <httpRuntime targetFramework="4.5.1" />
    <customErrors mode="Off">
      <error statusCode="404" redirect="~/Error/E404" />
    </customErrors>
    <httpHandlers>
      <add path="Reserved.ReportViewerWebControl.axd" verb="*" type="Microsoft.Reporting.WebForms.HttpHandler, Microsoft.ReportViewer.WebForms, Version=11.0.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91" validate="false" />
    </httpHandlers>
        <authentication mode="Forms" />
  </system.web>
iis-8 aspnetboilerplate
2个回答
1
投票

我还记得我第一次在ASP中实现表单身份验证。我只能说有一个原因我现在只做基于Linux的网络开发!

这是一个真正的痛苦,但如果您不打算使用数据库来管理用户,这应该可行。

如果您打算使用数据库,那么请为自己做好准备。你需要为正确的Visual Studio工具提供正确的MSSQL数据库,他们还完全删除了管理界面,因此你要么必须自己设计,要么使用互联网上可用的工具。我还记得我对它的整个想法感到非常沮丧,我真的编写了自己可以在开发网站上部署的管理工具。如果它没有在破碎的硬盘上,我会把它给你。

<authentication mode="Forms">  
  <forms loginUrl="login.aspx" defaultUrl="welcome.aspx">  
    <credentials passwordFormat="Clear">  
      <user name="abhishek" password="abhi@123"/>  
      <user name="Kantesh" password="sinha@123" />  
    </credentials>  
  </forms>  
</authentication>  
<authorization>  
  <deny users="?"/>
</authorization> 

如果您打算使用数据库来存储您的用户谷歌一些教程。

获得404的原因是因为您没有指定loginUrl,或者它不正确并且指向不存在的页面。

希望这可以帮助


1
投票

当您禁用对所有页面的匿名访问时,您也无法让用户查看登录页面。您需要做的是允许访问某些特定页面,如登录或注册。这可能不完全适合你,但你明白了。如果它不起作用,请尝试删除“/ account / login”的反斜杠“/”并将其设置为“account / login”

<configuration>
    <system.web>
        <authentication mode="Forms" />
        <authorization>
            <deny users="?" />  //this will restrict anonymous user access
       </authorization>
    </system.web>
    <location path="/account/login"> //path here is path to login page 
   <system.web><authorization><allow users="*" /> // this will allow access to everyone to login page 
 </authorization></system.web></location>
</configuration>
© www.soinside.com 2019 - 2024. All rights reserved.