如何使用 ASP.NET AJAX 实现 Windows Live ID 操作
好的,我正在使用 AJAX 和 Windows Live ID SDK 开发 ASP.NET Web 应用程序。 我已经成功地通过 Live 进行身份验证,但是...
Windows Live ID 规范表明我必须查找请求标头“登录”、“注销”和“clearcookie”。 推荐的代码示例包括 Response.Redirect,当您的页面广泛使用 UpdatePanels 时,它似乎不起作用:
loginCookie = new HttpCookie(strLoginCookie);
loginCookie.Expires = DateTime.Now.AddYears(-10);
Response.Cookies.Add(loginCookie);
Response.Redirect("default.aspx");
Response.End();
此外,clearcookie 操作要求我直接写入响应:
public WindowsLiveLogin wll = new WindowsLiveLogin(key1, key2);
loginCookie = new HttpCookie(strLoginCookie);
loginCookie.Expires = DateTime.Now.AddYears(-10);
Response.Cookies.Add(loginCookie);
string type;
byte[] content;
wll.GetClearCookieResponse(out type, out content);
Response.ContentType = type;
Response.OutputStream.Write(content, 0, content.Length);
因此,响应无法识别它并且 Windows Live 注销功能超时,无论是通过我的注销按钮(注销操作)还是 Windows Live 站点的注销功能(clearcookie 操作)执行此操作。 如何使用标记中的静态 UpdatePanels 和其他 AJAX 控件来实现这一点?
我在以前的 AJAX 项目中使用过它。 我决定不提供注销功能,当然可以通过清除 cookie 来绕过该功能。 请告诉我一个更优雅的方式!
OK, so I'm working on an ASP.NET webapp with AJAX and the Windows Live ID SDK. I've successfully gotten it to authenticate via Live, however...
The Windows Live ID spec indicates that I have to look for request headers "login", "logout", and "clearcookie". The recommended code samples include a Response.Redirect, which doesn't seem to work when your page has extensive use of UpdatePanels:
loginCookie = new HttpCookie(strLoginCookie);
loginCookie.Expires = DateTime.Now.AddYears(-10);
Response.Cookies.Add(loginCookie);
Response.Redirect("default.aspx");
Response.End();
Further, the clearcookie Action requires I write directly to the Response:
public WindowsLiveLogin wll = new WindowsLiveLogin(key1, key2);
loginCookie = new HttpCookie(strLoginCookie);
loginCookie.Expires = DateTime.Now.AddYears(-10);
Response.Cookies.Add(loginCookie);
string type;
byte[] content;
wll.GetClearCookieResponse(out type, out content);
Response.ContentType = type;
Response.OutputStream.Write(content, 0, content.Length);
As a result, the response doesn't recognize it and the Windows Live logout feature times out, whether doing it via my logout button (logout Action) or the Windows Live site's logout feature (clearcookie Action). How can this be accomplished with static UpdatePanels and other AJAX controls in the markup?
I used this in a former AJAX project. I settled for not having logout functionality, which of course can be bypassed by clearing one's cookies. Please tell me a more elegant way!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论