asp.net mvc 会话和自定义 MembershipProvider
问候, 在我的 ASP.NET MVC 应用程序中,我创建了一个自定义 MembershipProvider。它工作正常,但是当用户成功登录时,我想创建一个 Operator 对象并使其可以在每个控制器和视图上访问该对象。我正在考虑使用会话来执行此操作,但是当会话过期时,该对象为空,但使用 MembershipProvider 登录的用户仍然登录。有什么方法可以将我的 Operator 对象存储在 MembershipProvider 中并在每个控制器上访问它并查看我需要?
Greetings,
in my ASP.NET MVC application I've created a custom MembershipProvider. It works fine, however when user is successfully logged, I would like to create an Operator object and make it possible to access this object on every controller and view. I was thinking about session to do this but when session expires this object is null but user that had been logged using MembershipProvider is still logged in. Is there any way I can store my Operator object in MembershipProvider and access it on every controller and view I need?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许您应该使用 ApplicationState 而不是 SessionState?或者定义一个操作过滤器,检查会话是否是新的,然后重新加载登录用户所需的所有数据。
Maybe you should use the ApplicationState instead of the SessionState? Or define an action filter which checks if the session is new and then reloads all needed data for the logged-in user.