ASP.NET表单身份验证-不重定向到任何页面 [英] ASP.NET Forms Authentication - not redirecting to any page

查看:71
本文介绍了ASP.NET表单身份验证-不重定向到任何页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习ASP.NET,但对编程世界来说还是一个新手.

I'm in the process of learning ASP.NET and am still fairly new to the programming world.

在学习身份验证/授权的同时,我编辑了示例应用程序的Web配置文件以启用表单身份验证,并授权拒绝所有未登录的用户.我也创建了一个空白的Login.aspx表单,但是当我尝试执行该应用程序时,没有页面出现.IE显示:

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. I created a blank Login.aspx form as well, but when I try to execute the app, no pages appear. IE shows:

无法显示页面"

"Page can't be displayed"

即使我被告知应该自动重定向到我的 Login.aspx 文件.其他浏览器,例如Opera show:

even though I'm told it should redirect to my Login.aspx file automatically. Other browsers such as Opera show:

此网页具有重定向循环"

"This webpage has a redirect loop"

这是我到目前为止所拥有的:

This is what I have so far:

<system.web>
    ...
    <authentication mode="Forms" />
    <authorization>
        <deny users="?" />
    </authorization>
    ...
</system.web>

我尝试在< authentication/> 之间添加&form; forms 标记,并以 loginUrl 作为 Login.aspx,但仍然是相同的错误.我还添加了< location> 标记,以允许访问App_Themes和Images文件夹.

I tried adding the <forms> tag in between <authentication /> with loginUrl as Login.aspx, but still same error. I've also added the <location> tags to allow access to the App_Themes and Images folders.

我目前正在使用VS Express 2013 for Web与IIS Express集成.

I'm currently using VS Express 2013 for Web with IIS Express integrated.

任何帮助将不胜感激!

推荐答案

如果这对那里的人有帮助,我最终找到的解决方案是,在实现< forms> 标记时, loginUrl 属性的值应仅为登录表单的NAME,而无需 .aspx 扩展名.所以看起来像这样:

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. 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!

这篇关于ASP.NET表单身份验证-不重定向到任何页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆