title: Object reference not set to an instance of an object when checking for PostBack
body: <p>I have this code</p>
  
  <pre><code>if (PreviousPage.IsPostBack)
      {
          if (Request.Form["username"] == ConfigurationManager.AppSettings["username"] &amp;&amp; Request.Form["password"] == ConfigurationManager.AppSettings["password"])
          {
              Session["username"] = Request.Form["username"];
              using (var context = new mallEntities())
              {
                  var countProducts = (from p in context.Products
                                       select p).Count();
  
                  var countStores = (from p in context.Stores
                                     select p).Count();
  
                  var countCategories = (from p in context.Categories
                                         select p).Count();
  
                  Label3.Text = countProducts.ToString();
                  Label2.Text = countStores.ToString();
                  Label1.Text = countCategories.ToString();
              }
          }
          else
          {
              Response.Redirect("Default.aspx?invaild=true");
          }
      } else if(Session["username"] == null)
      {
          Response.Redirect("Default.aspx?session=false");
      }
  </code></pre>
  
  <p>and I got this error message:</p>
  
  <pre><code>Object reference not set to an instance of an object
  </code></pre>
  
  <p>at <code>PreviousPage.IsPostBack</code></p>
  
  <p>Why?</p>
  
  <p>What is the problem?</p>