如何访问会话以进行重写?
我正在尝试使用 HttpContext.Current.RewritePath 方法向不同的客户提供不同版本的应用程序。我希望能够查看 HttpContext.Current.Session 对象以了解是谁发出了请求。奇怪的是,当我在 BeginRequest
处理程序中查看此内容时,会话始终显示 null。我尝试过各种其他活动,但没有运气。对此有什么想法吗?
I'm trying to use the HttpContext.Current.RewritePath
method to serve up different versions of an application to different customers. I would love to be able to look at the HttpContext.Current.Session
object to know who it is making the request. Oddly when I go to look at this at the BeginRequest
handler, the Session always shows null. I've tried various other events and have had no luck. Any ideas on this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该查看 ASP.Net 应用程序生命周期概述 和MSDN 上的会话状态概述页面。
我相信您可以通过挂钩 Session_OnStart 事件来完成您想做的事情,该事件在创建新会话时都会触发。
You should look at the ASP.Net Application Life Cycle Overview and the Session State Overview pages on the MSDN.
I believe you can do what you're wanting to do by hooking into the Session_OnStart event, which is fired any time a new session is created.