Click here to Skip to main content
15,881,204 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
am having a asp.net project which has multiple folders and all .aspx file are in different folders and my global.asax file is in root folder now i am trying to get the value of Session variable but its giving me error of object not set to an instance .

I have already tried of making a class object and accessing it but its giving me "Session State is not available in this context"

Please help me so that i can achieve my target.

Thank You
Posted
Comments
Raul Iloc 28-Jul-14 6:59am    
You should describe more exactly the context (what you are trying to do, details regarding your existing code, etc) of your problem and to provide also some source code, in order to can help you
ZurdoDev 28-Jul-14 8:25am    
You would have to post your code for us to know what you did wrong.

Try to use
C#
HttpContext.Current.Session["varName"];

It should work.

   --Amy
 
Share this answer
 
I am not sure, where are you setting the Session Variable. But If you are setting your Session Variable in Application_Start in Global.asax file. Then It will not work.
You need to set a Session in Application_AcquireRequestState block.
Eg.
C#
protected void Application_AcquireRequestState(object sender, EventArgs e)
{
    Session["ExampleKey"] = "Example Value";
}


Good luck.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900