验证继承System.Security.Principal.IPrincipal 接口和System.Security.Principal.IIdentity接口
。这些都正常,正常登陆后跳到成功页,在login.aspx中在成功登陆后取Context.User.Identity.IsAuthenticated的值为True。除了这页。其它页的值匀为false.也就是登陆后只能在本页起作用。在别的页都是没有验证过的。这是Login.aspx.cs的代码。登陆成功后跳转我在此页登陆成功后输出if (Context.User.Identity.IsAuthenticated)
{
Response.Write(Context.User.Identity.Name);Response.End();
}
这样能得到值。我在登陆成功页Default.aspx中无法取到值。Context.User.Identity.IsAuthenticated的值为false我是参照Asp.Net web站点高级编程做的。ThePhile哪位知道帮偶看看。困惑了好久.
private void Submit_Click(object sender, System.EventArgs e)
{
PhilePrincipal newUser = PhilePrincipal.ValidateLogin( EmailAddress.Text, Password.Text );
if (newUser == null)
{
LoginResult.Text = "Login failed for " + EmailAddress.Text; LoginResult.Visible = true;
}
else
{ Context.User = newUser; FormsAuthentication.SetAuthCookie( EmailAddress.Text, true );
Response.Redirect("/default.aspx");
}
}
。这些都正常,正常登陆后跳到成功页,在login.aspx中在成功登陆后取Context.User.Identity.IsAuthenticated的值为True。除了这页。其它页的值匀为false.也就是登陆后只能在本页起作用。在别的页都是没有验证过的。这是Login.aspx.cs的代码。登陆成功后跳转我在此页登陆成功后输出if (Context.User.Identity.IsAuthenticated)
{
Response.Write(Context.User.Identity.Name);Response.End();
}
这样能得到值。我在登陆成功页Default.aspx中无法取到值。Context.User.Identity.IsAuthenticated的值为false我是参照Asp.Net web站点高级编程做的。ThePhile哪位知道帮偶看看。困惑了好久.
private void Submit_Click(object sender, System.EventArgs e)
{
PhilePrincipal newUser = PhilePrincipal.ValidateLogin( EmailAddress.Text, Password.Text );
if (newUser == null)
{
LoginResult.Text = "Login failed for " + EmailAddress.Text; LoginResult.Visible = true;
}
else
{ Context.User = newUser; FormsAuthentication.SetAuthCookie( EmailAddress.Text, true );
Response.Redirect("/default.aspx");
}
}
解决方案 »
- 多条件查询语句
- aspnetpager6.0 页面回发后,分页脚本出错
- 关于petshop4的OracleDAL问题.(高分,在线等)
- 求救:請教高手,關于頁面加載程序
- asp.net到底是先用dreamweaver做好框架还是先在.net里写好代码?
- (急!!!)高手进(datalist 怎样排出这样的效果!!)
- 拜师了:asp.net入门
- 如何只显示时分秒不显示年月日?
- ASP.NET MVC如何用SQL SERVER2012建立Model层
- 请大家帮帮忙,急
- 关于动态加载DataList模版的问题。。。。。
- 200!!!!!求vb写的webserver接收XML,分析数据后再返回xml的代码
{
if (!(Context.User is SitePrincipal))
{
// ASP.NET's regular forms authentication picked up our cookie, but we
// haven't replaced the default context user with our own. Let's do that
// now. We know that the previous context.user.identity.name is the e-mail
// address (because we forced it to be as such in the login.aspx page)
SitePrincipal newUser = new SitePrincipal( Context.User.Identity.Name );
Context.User = newUser;
}
}
但就只是在login.aspx页面里可以读验证过的信息
PageBase重写了页面载入。的这些我都加上了,还是一样。哎!
并且我也验证了PageBase_load里的东东确实执行了。但执行到验证是否通过时
还是没有通过。!@
Identity
Principal
类
创建身份验证票并将其附加到 Cookie 的传出响应的集合。它不执行重定向
不知道此方法key的值是按什么来创建的
好像是按工程名或者虚拟目录的名称创建建的
Thephile的用此方法后Cookie的key的值值为Thephile
而我建的如果是根目录的话key值为.aspxauth
如果是虚拟目录的话
我的工程得到的key的值却不为虚拟目录的名称
可能是这里不同吧。但我也不知道该改哪里。
里没有采用Forms认证。晕!
原来是这个。我记得改过来的1