简体   繁体   English

当我将Default.aspx设置为默认页面时,IIS保持重定向到Login.aspx

[英]IIS Keeps Redirecting to Login.aspx when I set Default.aspx as default page

IIS Keeps Redirecting me to Login.aspx when I set Default.aspx as default page. 当我将Default.aspx设置为默认页面时,IIS会将我重定向到Login.aspx In my dev environment its working fine, I get to the right page, but as soon as I publish and try from the IIS server login.aspx always comes first. 在我的开发环境中,它的工作正常,我进入了正确的页面,但是一旦我发布并从IIS服务器尝试登录,login.aspx始终排在第一位。

I have made sure anon users are allowed : 我确保允许匿名用户:

  <location path="Default.aspx">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>

And its set as default url (further down the config) : 并将其设置为默认网址(进一步向下配置):

<authentication mode="Forms">
  <forms loginUrl="Login.aspx" defaultUrl="Default.aspx"></forms>
</authentication>
<authorization>
  <deny users="?" />
</authorization>

I even set the default page in IIS, but it resets it every time on publish. 我什至在IIS中设置了默认页面,但每次发布时都会将其重置。

Try adding the Authenticated User to the security property of the web folder in IIS. 尝试将经过身份验证的用户添加到IIS中Web文件夹的安全性属性中。 Give the modify privilege (Read, Write, Modify, List Folder Content, Read & execute) to this user. 授予该用户修改权限(读取,写入,修改,列出文件夹内容,读取和执行)。

This of course should only be a temporary situation to verify that you have a permission issue. 当然,这仅是暂时的情况,以验证您是否存在权限问题。 You should consider setting proper permissions for site users. 您应该考虑为站点用户设置适当的权限。

//Peace //和平

I spent about 6 hours debugging the issue. 我花了大约6个小时来调试问题。 Our website was working fine, and suddenly it started redirecting to login page instead of default page (unauthenticated). 我们的网站运行正常,突然开始重定向到登录页面,而不是默认页面(未经身份验证)。 Our web.config included all authentication/authorization settings correctly. 我们的web.config正确包含了所有身份验证/授权设置。

    <authentication mode="Forms">
      <forms name="MyAuth" path="/" loginUrl="login.aspx" protection="All" timeout="30" />
    </authentication>
    <authorization>
      <deny users="?" />
    </authorization>

  <system.webServer>
    <defaultDocument>
      <files>
        <clear />
        <add value="default.htm" />
      </files>
    </defaultDocument>
...
  </system.webServer>

  <location path="default.htm">
    <system.web>
      <authorization>
        <allow users="?" />
      </authorization>
    </system.web>
  </location>

... ...

SOLUTION: You need to remove Extensionless URL feature from your website. 解决方案:您需要从网站中删除无扩展名URL功能。 Ref: https://support.microsoft.com/en-us/help/2526854/users-may-be-redirected-to-the-login-page-of-an-asp-net-4-application 参考: https : //support.microsoft.com/zh-cn/help/2526854/users-may-be-redirected-to-the-login-page-of-an-asp-net-4-application

<system.webServer>

     <handlers>
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
          <remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
          <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
     </handlers>

     <validation validateIntegratedModeConfiguration="false" />

</system.webServer>

After the fix, the website was back to normal. 修复后,网站恢复正常。

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

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