title: Object reference not set to an instance of an object in ASP.NET
body: <p>I am developing a School Management System in Asp.net and C#.
  I have created a login page when i click to login an error occoured that 
  Object reference not set to an instance of an object.</p>
  
  <p>Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. </p>
  
  <blockquote>
    <p>Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
    Source Error: </p>
  </blockquote>
  
  <pre><code>public string connectionString()
  {
      string connString = ConfigurationManager.ConnectionStrings["SchoolConnectionString1"].ConnectionString;
      return connString;
  }
  </code></pre>
  
  <blockquote>
    <p>Source File: C:\Users\ALI\Desktop\Final Project\SchoolERP\SchoolERP\Connection\MyConnection.cs    Line: 14 </p>
  </blockquote>
  
  <p>My Stack Trace is given under</p>
  
  <p>Stack Trace: </p>
  
  <blockquote>
    <p>[NullReferenceException: Object reference not set to an instance of an object.]
         SchoolERP.Connection.MyConnection.connectionString() in C:\Users\ALI\Desktop\Final                  SchoolERP.Connection.MyConnection.connectionString() in C:\Users\ALI\Desktop\Final Project\SchoolERP\SchoolERP\Connection\MyConnection.cs:14
               SchoolERP.Pages.Membership.Logout.btnLogout_Click(Object sender, EventArgs e) in C:\Users\ALI\Desktop\Final Project\SchoolERP\SchoolERP\Pages\Membership\Logout.aspx.cs:26
               System.Web.UI.WebControls.Button.OnClick(EventArgs e) +118
             System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
               System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
        System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
        System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5563</p>
  </blockquote>