c# - Get item from list collection in asp.net session + object reference not set to instance of an object -


i created sessionmanager class in order handle session variables in asp.net application. following piece of sessionmanager class code:

    public int totaltests     {                 {             return (int)httpcontext.current.session["totaltests"];         }         set         {             httpcontext.current.session["totaltests"] = value;         }     }      public list<testcase> testcases     {                 {             return (list<testcase>)httpcontext.current.session["testcases"];         }         set         {             httpcontext.current.session["testcases"] = value;         }     } 

the issue able set , access value of totaltests both code-behind , other classes in web app. regard testscases able assign collection of list type code-behind, , debugging application shows session variable getting populated, when try retrieve item collection stored in session using linq object reference not set instance of object error. code i'm using below:

testcase test = (from testcase in session.testcases                         testcase.testname == result.name                         select testcase).single(); 

and populate the collection in session used

sessionmanager session = new sessionmanager(); session.testcases = testcases;

any idea please might causing this?


Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -