简体   繁体   English

自动重定向到登录页面

[英]Auto redirect to login page

In my web config, I've specified: 在我的网络配置中,我已经指定:

<authentication mode="Forms">
  <forms name=".ASPXFORMSAUTH" loginUrl="~/SignIn.aspx" defaultUrl="~/Secure/Default.aspx" timeout="20" requireSSL="false"/>
</authentication>
<authorization>
  <allow users="*"/>
  <deny users="?"/>
</authorization>

I assumed that no matter what page I tried to browse to initially, the asp.net framework would automatically redirect me to the signin page, but this is not the behavior I'm experiencing. 我假设无论我最初尝试浏览哪个页面,asp.net框架都会自动将我重定向到登录页面,但这不是我遇到的行为。 Am I missing something? 我错过了什么吗?

You have allow users = *, remove that line because it by default logs in every user. 您已允许users = *,删除该行,因为默认情况下会记录每个用户。 login url will be hit when a user is not authenticated but you are by default authenticating all the users. 如果用户未经过身份验证但您默认情况下会对所有用户进行身份验证,则会触发登录URL。

You should revert the authorization element so that it disallows anonymous users first. 您应该还原授权元素,以便它首先禁止匿名用户。

<authorization>
  <deny users="?"/>
  <allow users="*"/>
</authorization>

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

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