asp.net窗体身份验证的变化.NET 2 .NET4 [英] asp.net Form Authentication change .net 2 to .net4

查看:113
本文介绍了asp.net窗体身份验证的变化.NET 2 .NET4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的窗体身份验证部分从我的web.config

Here is my forms authentication section from my web.config

<authentication mode="Forms">
  <forms name="security" path="/" loginUrl="default.aspx" protection="All" timeout="360" />
</authentication>

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

由于某种原因,更改为.NET 4中为我的目标后,人们纷纷登陆前两次我的形式进行验证,就会重定向。有没有其他人遇到了这个。

For some reason after change to .net 4 as my target, people have to login twice before my form authentication redirects now. Has anyone else run into this.

也是我的登录是在首页,所以我尝试了以下思考我只是需要让我的登录页面公开,但没有奏效。任何人有这个问题?

Also my login is in the homepage so I tried the below thinking I just need to make my login page public, but it did not work. Anyone else have this problem?

此外,我注意到,当我访问我的主页,我得到这个在URL中的的Default.aspx?RETURNURL =%2F ,如果我删除了RETURNURL参数,然后它的工作原理登录第一次。但是,如果RETURNURL在查询字符串我必须先登录第一次访问该网站的两倍。

Also I noticed that soon as I visit my homepage I get this in the url default.aspx?ReturnUrl=%2f, if I remove the ReturnUrl parameter, it then works to login first time. But if ReturnUrl is in querystring I have to login twice the first time visiting the site.

的Default.aspx?RETURNURL =%2F

default.aspx?ReturnUrl=%2f

所以我加入了网页在我的位置公共接入,这并没有帮助。

So I added the page to public access in my locations and this didn't help..

<location path="default.aspx">
<system.web>
  <authorization>
    <allow users="*" />
    <deny users="?" />
  </authorization>
</system.web>

推荐答案

在你的URL是这样的:Default.aspx的RETURNURL =%2F,登录后,它会重定向回默认页,这是默认的页面。如果您添加code默认页面:

When your URL is this: default.aspx?ReturnUrl=%2f, after logging in, it redirects back to the default page, which is the default page. If you added code to the default page:

If (this.User.Identity.IsAuthenticated)
{
    Response.Redirect("somepage.aspx");
}

这个问题就会迎刃而解。这不是因为他们必须先登录两次,那是因为他们继续回来到默认的页面。

This problem will go away. It's not because they have to login twice, it's because they keep coming back to the default page.

这篇关于asp.net窗体身份验证的变化.NET 2 .NET4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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