ASP.NET - 访问会话从静态方法/静态类? [英] ASP.NET - Access Session from static method/static class?

查看:114
本文介绍了ASP.NET - 访问会话从静态方法/静态类?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想访问会话对象而不将它传递给我的静态辅助功能。

这是这样我就可以从会话对象会自动以最小的额外绒毛保存和加载的东西。

是否有可能/我如何可以访问会话对象从静态方法中的一个静态类?


解决方案

  HttpContext.Current.Session

MSDN:<一href=\"http://msdn.microsoft.com/en-us/library/system.web.httpcontext.current%28v=vs.110%29.aspx\">http://msdn.microsoft.com/en-us/library/system.web.httpcontext.current(v=vs.110).aspx

I would like to access the session object without passing it to my static helper function.

This is so I can save and load things from the session object automatically with minimum extra fluff.

Is it possible/how can I access the session object from within a static method in a static class?

解决方案

HttpContext.Current.Session

MSDN: http://msdn.microsoft.com/en-us/library/system.web.httpcontext.current(v=vs.110).aspx

这篇关于ASP.NET - 访问会话从静态方法/静态类?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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