Object reference not set to an instance of an object error
Object reference not set to an instance of an object error in a line - strUserSanctionLevel = Session["UserSanctionLevel"].ToString();
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.

Akhil GargRank #772 · 3K reputationPosted Apr 10, 2015, 2:26 AM EDT
First Initialize
String strUserSanctionLevel=new String();
then write
strUserSanctionLevel = Session["UserSanctionLevel"].ToString();
or Session["UserSanctionLevel"] is null so use Convert.ToString(Session["UserSanctionLevel"]) instead of direct ToString();
Khargesh RajputRank #616 · 3.9K reputationPosted Apr 10, 2015, 2:28 AM EDT
if(Session["UserSanctionLevel"]!=null)
{
strUserSanctionLevel = Session["UserSanctionLevel"].ToString();
}
Shubham KumarRank #621 · 3.8K reputationPosted Apr 10, 2015, 4:00 AM EDT
"Object reference not set to an instance of an object" means your object's instance is not made and you are trying to perform operation on it just first create your instance :) and you will get the answer