[英]ASP.NET Forms Authentication - not redirecting to any page
I'm in the process of learning ASP.NET and am still fairly new to the programming world. 我正在学习ASP.NET,但对编程世界来说还是一个新手。
While learning about authentication/authorization
, I edited my sample app's web config file to enable forms authentication, and authorization to deny all non-logged in users. 在了解
authentication/authorization
,我编辑了示例应用程序的Web配置文件以启用表单身份验证,并授权拒绝所有未登录的用户。 I created a blank Login.aspx form as well, but when I try to execute the app, no pages appear. 我也创建了一个空白的Login.aspx表单,但是当我尝试执行该应用程序时,没有页面出现。 IE shows:
IE显示:
"Page can't be displayed"
“页面无法显示”
even though I'm told it should redirect to my Login.aspx
file automatically. 即使有人告诉我它应该自动重定向到我的
Login.aspx
文件。 Other browsers such as Opera show: 其他浏览器(例如Opera)显示:
"This webpage has a redirect loop"
“此网页有重定向循环”
This is what I have so far: 这是我到目前为止的内容:
<system.web>
...
<authentication mode="Forms" />
<authorization>
<deny users="?" />
</authorization>
...
</system.web>
I tried adding the <forms>
tag in between <authentication />
with loginUrl
as Login.aspx
, but still same error. 我尝试在
<authentication />
之间添加<forms>
标记,并使用loginUrl
作为Login.aspx
,但是仍然出现相同的错误。 I've also added the <location>
tags to allow access to the App_Themes and Images folders. 我还添加了
<location>
标记,以允许访问App_Themes和Images文件夹。
I'm currently using VS Express 2013 for Web with IIS Express integrated. 我目前正在使用VS Express 2013 for Web与IIS Express集成。
Any help would be appreciated! 任何帮助,将不胜感激!
If this helps anyone out there, I finally found the solution to be that, when implementing the <forms>
tag, the loginUrl
attribute should have a value of just the NAME of the login form, WITHOUT the .aspx
extension. 如果这对那里的任何人都有帮助,我最终找到了解决方案,即在实现
<forms>
标记时, loginUrl
属性的值应仅为登录表单的NAME值,而没有.aspx
扩展名。 So it looks like this: 所以看起来像这样:
<system.web>
<authentication mode="Forms">
<forms loginUrl="~/Login" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
Thanks to whoever that tried to help! 感谢试图帮助的人!
Enable Anonymous Authentication in the IIS and then try. 在IIS中启用匿名身份验证,然后尝试。
Run->ingetmgr->IIS Group->Authentication->RightClick on Anonymous Authenticaion and Enable. 运行-> ingetmgr-> IIS组->身份验证->右键单击“匿名身份验证并启用”。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.