Praveenu Veenu

Praveenu Veenu

  • NA
  • 9
  • 823

Object reference not set to an instance of an object

Mar 9 2016 7:54 AM
Hi, 
I'm getting this error while running following code. 
 

Server Error in '/' Application.

Object reference not set to an instance of an object.

private void CheckFriendshipStatus()
{
var obj1 = Session["UserId"].ToString();
var obj2 = Session["CurrentProfileId"].ToString();
if (obj1 == obj2)
{
btnAddAsFriend.Visible = false;
}
I also tried 
private void CheckFriendshipStatus()
{
if (Object.Equals(Session["UserId"].ToString(), Session["CurrentProfileId"].ToString()))
{
btnAddAsFriend.Visible = false;
}
 
I couldn't solve this please help me to solve this. 

Answers (4)