title: Session error :Object not set to an instance
body: <p>In my webpage I'm not able to get the session variable on post back in remote server.</p>
  
  <p>The problem is </p>
  
  <p>if the page is not IsPostback then I'm able to get the session variable.</p>
  
  <p>But if the page postback then the error appears.</p>
  
  <p>This same error comes when i use the asynchfile upload. I'm using asynchfileupload to upload a image and store it to a session variable. and later on button click i am saving data to directory.</p>
  
  <p>this problem arouse when i upload any files to the server.i am using the asynchfileupload control to upload the image.,but it is not occuring frequently.</p>
  
  <p>here is my code</p>
  
  <pre><code>protected void AsynImageLoader_UploadedComplete(object sender, AjaxControlToolkit.AsyncFileUploadEventArgs e)
  {
      if (AsynImageLoader.PostedFile != null)
      {
          string extension = System.IO.Path.GetExtension(AsynImageLoader.PostedFile.FileName);
  
          if (extension == ".jpg" || extension == ".gif" || extension == ".jpeg" || extension == ".png")
          {
              HttpPostedFile file = AsynImageLoader.PostedFile;
              Session["TempImage"] = ReadFile(file);
          }
      }
  }
  </code></pre>
  
  <p>on button click</p>
  
  <pre><code>   var storedImage = Session["TempImage"] as byte[];
     String Strthumbpath = Server.MapPath("content\\thumbnail\\");
     if (storedImage != null)
     {
         System.Drawing.Image image = GetImage(storedImage);
         if (image != null)
         {
         image.Save(Strthumbpath + strFileName);
         }
  
         }
  </code></pre>
  
  <p>inserting values to datbase.</p>
  
  <p>after somuch googling i read that when any files is adding to any sub directory or editing the webconfig will cause cause the application to restart.</p>
  
  <p>if so how can i solve this..</p>
  
  <p>thanks in advance.</p>