title: Object reference not set to an instance of an object working with ASP.NET Project
body: <p>I'm having an issue comparing 2 objects in an ASP.NET Project, I'm not sure if I am a beginner or what but this is my actual code: </p>
  
  <pre><code>private void CheckFriendshipStatus()
      {
  
  
          if (Object.ReferenceEquals(Session["UserId"].ToString(), Session["CurrentProfileId"].ToString()))
          {
              btnAddAsFriend.Visible = false;
          }
          else
          {
              DataTable dt1 = new DataTable();
              string chkfriendRequest = "SELECT * FROM Friends WHERE (MyId='" + Session["UserId"].ToString() + "' and FriendId='" + Session["CurrentProfileId"].ToString() + "') OR (MyId='" + Session["CurrentProfileId"].ToString() + "' and FriendId='" + Session["UserId"].ToString() + "')";
  </code></pre>
  
  <p>Then I tried: </p>
  
  <pre><code>    var obj1 = Session["UserId"].ToString();
      var obj2 = Session["CurrentProfileId"].ToString();
  
  
          if (obj1 == obj2)
          {
              btnAddAsFriend.Visible = false;
          }
      else
      {
  </code></pre>
  
  <p>and then I tried setting the value to null first and then assigning the session values. I'm out of ideas, any other one will be highly appreciated </p>