如何在其他项目中的Class文件中获取Session [C#Project] [英] How to get Session in Class file which is in other project[C# Project]
本文介绍了如何在其他项目中的Class文件中获取Session [C#Project]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在我的班级文件中,我无法访问会话.
类在另一个Project [C#Project]中,并且该类已经继承了另一个类.
我无法使用HttpContext或Page对象进行访问.
Plzz帮助.
In my class file i am not able to access Session.
Class is in another Project[C# Project] and class already inheriting another class.
I am not able to access using HttpContext or Page objects.
Plzz Help.
推荐答案
如果您在类库中引用System.Web,则只要您在Web上下文中运行并且启用并配置了会话状态,它将可以正常工作. :
If you reference System.Web in your class library it will work provided you''re running in a web context and have session state enabled and configured:
var value = HttpContext.Current.Session["SomeSessionValue"];
请澄清,如果可能,请提供代码块
please clarify, If possible please provide the code block
这篇关于如何在其他项目中的Class文件中获取Session [C#Project]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文