asp.net Windows Live ID认证

来源:百度知道 编辑:UC知道 时间:2024/06/05 21:56:54
现在我可以使用windows live ID 认证中SDK中的例子了。
但是我想,如果用户登陆成功后就跳转到其他页面,比如suc.aspx;
那么,当用户直接在IE地址栏输入http://localhost/suc.aspx,如何判断用户当前没有登陆?怎么才能做到没有登陆的时候,永远跳转到登陆页面?

在线等,希望有人帮忙,十分感激

HttpRequest req = HttpContext.Current.Request;
HttpCookie loginCookie = req.Cookies[LoginCookie];

if(loginCookie != null){
string token = loginCookie.Value;

if (!string.IsNullOrEmpty(token))
{
WindowsLiveLogin.User user = wll.ProcessToken(token);

if (user != null)
{
UserId = user.Id;
}
}
}
else
{
Response.Redirect("http://login.live.com/controls/WebAuth.htm?appid=" + AppId + "&style=font-size%3A+10pt%3B+font-family%3A+verdana%3B+background%3A+white%3B");
}