开发者

Access the current session variable from another controller

I called a method from another controller using this

AnotherController oriCon = new AnotherController();
oriCon.ApproveOperation(formCollection, ref responseMsg);

Now, inside the ApproveOperation method, I called the session variable like this

int activeUser = (int)HttpContext.Session["user"];

But its giving me error; null value

I've asked before in forums.asp.net, someone told me to use

HttpContext.Current.Session

But I can't use that, there is no Current property in my HttpContext. Did I have no Current property because I'm using MVC 1.0 framework 3.5. Maybe the guy who answered me using MVC 2.0 framework 4.0?

开发者_StackOverflow

Can anyone give me light on this?


What do you mean "called a method from another controller"?

I don't think you should be doing that. If its a common function that is used by two different controllers then put it in a separate class and then use it. You should be able to access Session from all your controller.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜