Ahmed Khalid

Ahmed Khalid

  • NA
  • 114
  • 5.5k

Object reference not set to an instance of an object.

Dec 1 2022 10:08 AM

Hi,

I have implemented Session in Master Page and in Login Pages for User and Admin in my application. The application is working fine but it frequently prompts "Object reference not set to an instance of an object." during Login process and whenever the home page is being displayed or page gets refreshed and it stops at if (Session["role"].Equals("")) in debug mode

I tried to comment the  if (Session["role"].Equals("")) and keep the if (Session["role"].Equals("user")) and if (Session["role"].Equals("admin")) un commented. But behaviour remains the same. 

Any idear please?


Answers (4)