表单身份验证未按预期工作
我第一次尝试使用表单身份验证。这就是我在 web.config 中的内容:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" name="Login" slidingExpiration="true" timeout="30" path="/">
</forms>
</authentication>
<authorization>
<allow users="*" />
</authorization>
我正在处理的网站实际上不需要任何身份验证,因为该页面应该无需登录即可访问。这就是我允许所有用户的原因。我对此很陌生,所以可能有一些明显的我做错了,但所有页面似乎都重定向到 Login.aspx,即使我允许所有用户。
非常感谢所有帮助。谢谢。
更新: 按照一个答案的指示,我将代码更改为下面的代码(将 * 更改为?),但我仍然遇到同样的问题:
<authorization>
<allow users="?" />
</authorization>
I am trying to use Forms Authentication for the first time. This is what I have in my web.config:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" name="Login" slidingExpiration="true" timeout="30" path="/">
</forms>
</authentication>
<authorization>
<allow users="*" />
</authorization>
The website I am working on doesn't actually need any authentication because the page should be accessible without logging in. So that's why I'm allowing all users. I am very new to this so there's probably something obvious I'm doing wrong, but all pages seem to redirect to Login.aspx, even though I'm allowing all users.
All help is very much appreciated. Thanks.
UPDATE:
As one answer directed, I changed the code to the below (changed * to ?) but I still have the same problem:
<authorization>
<allow users="?" />
</authorization>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
星号代表任何经过身份验证的用户,不包括匿名用户。使用问题允许匿名用户:
Asterisk stands for any authenticated user which does not include anonymous users. Use question to allow anonymous users:
我来到这个页面时遇到了同样的问题,并且看到 5 年后这个问题从未得到正确的回答。您需要在 web.config 中指定以下内容:
这意味着您拒绝所有匿名用户的访问,并允许所有用户的访问经过身份验证的用户。
I came at this page having the same problem, and see that 5 years later this has never been properly answered.. You needed to specify the following in web.config:
Meaning that you deny access to all anonymous users, and allowing access to all authenticated users.