English 中文(简体)
如同p.net mvc,在控制器施工期间,在任何时间都可以开课?
原标题:asp.net mvc is Session available at any point during controller construction?

i 试图获取控制员和主计长的构造中的会议变数似乎总是无效。

届会的最早变量何时可以实现?

感谢!

Edit: Example:

在一名控制员中:

public HomeController()
    {
        MyClass test =   (MyClass)ControllerContext.HttpContext.Session["SessionClass"];
    //ControllerContext always null           
    }

当分解时,控制器的文字是ALWAYS。 在控制器中,其行动方向转向该控制器,即:

Session["SessionClass"] = class;

MyClass test = (MyClass )ControllerContext.HttpContext.Session["SessionClass"]; 
// this works fine! i can get varibale from session

return RedirectToAction("Index", "Home");

因此,在什么时候,主计长实际确定了什么内容? 何时我能进入会议变量?

最佳回答

Override Initialize(:

protected override void Initialize(System.Web.Routing.RequestContext requestContext)
{
    base.Initialize(requestContext);
    requestContext.HttpContext.Session["blabla"] = "hello"; // do your stuff
}
问题回答

暂无回答




相关问题
why the session in iis automatically log out?

I used iis6, and when i called a function Directory.delete(), the all the session relate this website will be logged out. and i debugged the website, i found no exception. any one have ideas on this ? ...

Check session from a view in CodeIgniter

What is the best way to check session from a view in CodeIgniter, it shows no way in their user guide, otherwise I will have to make two views on everything, which is kinda weird...still a newbie to ...

Can I get the size of a Session object in bytes in c#?

Is it possible to get the size(in bytes) of a Session object after storing something such as a datatable inside it? I want to get the size of a particular Session object, such as Session["table1"], ...

提供严格分类的出席会议物体

提供严格分类的与会机会的最佳方式是什么? 我正计划转而选择矩阵,这正在促使汇编者抱怨我的幻觉方案拟订方法......

PHP Session is not destroying after user logout

I m trying to create an authentication mechanism for my PHP Application and I m having difficulty destroying the session. I ve tried unsetting the authentication token which was previously set within ...

热门标签