在session_end事件中访问表单身份验证cookie [英] Access forms authentication cookies in session_end event

查看:109
本文介绍了在session_end事件中访问表单身份验证cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在global.asax的session_end事件中访问Forms身份验证。基本上,我想获得存储在cookie中的加密ID,并根据我想要更新用户详细信息的ID。



我尝试过:



我试图访问cookie,但它总是给我一个空引用。

解决方案

< blockquote>此事件中不提供http上下文,因此您将无法访问cookie。相反,您可以使用Application状态,并在用户通过身份验证后将userid添加到应用程序变量。现在,在session_end事件上,您可以从应用程序变量中获取userid,并在同一事件中将其设置为null。我希望这会有所帮助。


I want to access Forms Authentication in global.asax's session_end event. basically, i want to get encrypted id which is stored in the cookie and based on that id I want to update user details.

What I have tried:

I have tried to access cookie but it always gives me a null reference.

解决方案

The http context is not available in this event so you will not be able to access cookie. Instead you can use Application state and add userid to application variable once user is authenticated. Now, on session_end event you can fetch userid from application variable and set it to null in the same event. I hope this helps.


这篇关于在session_end事件中访问表单身份验证cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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