Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Asp.net-mvc: Calling Session_Start in global.asax

I am using visual studio 2015 and asp.net mvc and I want to initialize a session variable in the Session Start method but im not sure about the signature of the method and i couldn't find documentation about it

Here is what i have as of now in my global.asax file :

 public void Session_Start()
    {
        InscriptionPaiementEntities dbm = new InscriptionPaiementEntities();
        var NbreItemMax = dbm.INSC_config.Where(p => p.NomParametre == 
         "NbreItemMax").FirstOrDefault();
        Session["NbreItemMax"] = NbreItemMax.Texte;
    }

Any Help would be gladly appreciated

like image 796
Louis-Roch Tessier Avatar asked Apr 05 '17 13:04

Louis-Roch Tessier


1 Answers

Adjust the method signature.

protected void Session_Start(Object sender, EventArgs e) 
{
   InscriptionPaiementEntities dbm = new InscriptionPaiementEntities();
   var NbreItemMax = dbm.INSC_config.Where(p => p.NomParametre == 
         "NbreItemMax").FirstOrDefault();
   Session["NbreItemMax"] = NbreItemMax.Texte;
}
like image 96
William Xifaras Avatar answered Nov 11 '22 03:11

William Xifaras