无法为ASP.NET MVC5站点配置Windows身份验证

时间:2017-07-12 19:02:47

标签: asp.net web-config windows-authentication asp.net-mvc-5.2 asp.net-authorization

我有一个使用OWIN身份验证的网站。但是,所有工作都很完美,我需要限制此网站的访问权限,然后再将其发布给公众。

为了实现这一点,我想让系统在加载主页之前显示Windows身份验证对话框。

我把它放在网站的web.config中:

<system.web>
    <customErrors mode="Off" />
    <compilation targetFramework="4.6" />
    <httpRuntime targetFramework="4.6" />
    <authentication mode="Windows" />
    <globalization culture="es-CL" uiCulture="es" />
    <authorization>
        <deny users="?"/>
        <allow users="Demo" />
    </authorization>
  </system.web>

但是主页不起作用。

当我尝试加载主页时,会加载此实际网址:

http://demo.site.cl/Security/Account?ReturnUrl=%2FSecurity%2FAccount%3FReturnUrl%3D%252FSecurity%252FAccount%253FReturnUrl%253D%25252FSecurity%25252FAccount%25253FReturnUrl%25253D%2525252FSecurity%2525252FAccount%2525253FReturnUrl%2525253D%252525252FSecurity%252525252FAccount%252525253FReturnUrl%252525253D%25252525252FSecurity%25252525252FAccount%25252525253FReturnUrl%25252525253D%2525252525252FSecurity%2525252525252FAccount%2525252525253FReturnUrl%2525252525253D%252525252525252FSecurity%252525252525252FAccount%252525252525253FReturnUrl%252525252525253D%25252525252525252FSecurity%25252525252525252FAccount%25252525252525253FReturnUrl%25252525252525253D%2525252525252525252FSecurity%2525252525252525252FAccount%2525252525252525253FReturnUrl%2525252525252525253D%252525252525252525252FSecurity%252525252525252525252FAccount%252525252525252525253FReturnUrl%252525252525252525253D%25252525252525252525252FSecurity%25252525252525252525252FAccount%25252525252525252525253FReturnUrl%25252525252525252525253D%2525252525252525252525252FSecurity%2525252525252525252525252FAccount%2525252525252525252525253FReturnUrl%2525252525252525252525253D%252525252525252525252525252FSecurity%252525252525252525252525252FAccount%252525252525252525252525253FReturnUrl%252525252525252525252525253D%25252525252525252525252525252FSecurity%25252525252525252525252525252FAccount%25252525252525252525252525253FReturnUrl%25252525252525252525252525253D%2525252525252525252525252525252FSecurity%2525252525252525252525252525252FAccount%2525252525252525252525252525253FReturnUrl%2525252525252525252525252525253D%252525252525252525252525252525252FSecurity%252525252525252525252525252525252FAccount%252525252525252525252525252525253FReturnUrl%252525252525252525252525252525253D%25252525252525252525252525252525252FSecurity%25252525252525252525252525252525252FAccount%25252525252525252525252525252525253FReturnUrl%25252525252525252525252525252525253D%2525252525252525252525252525252525252FSecurity%2525252525252525252525252525252525252FAccount%2525252525252525252525252525252525253FReturnUrl%2525252525252525252525252525252525253D%252525252525252525252525252525252525252F

显示404错误。

如何做到这一点?

0 个答案:

没有答案