title: An exception of type 'System.OutOfMemoryException' occurred in mscorlib.dll but was not handled in user code
body: <p>I am uploading larger video files say 1 GB Size from Admin Panel but whenever i try to upload larger files i get "'System.OutOfMemoryException'" error.
  Here is my code :</p>
  
  <pre><code> protected void btnUpload_Click(object sender, EventArgs e)
          {
              using (BinaryReader br = new BinaryReader(FileUpload1.PostedFile.InputStream))
              {
                  byte[] bytes = br.ReadBytes((int)FileUpload1.PostedFile.InputStream.Length);
                  string _connString = ConfigurationManager.AppSettings["connString"];
                  int id=1;
                  using (SqlConnection con = new SqlConnection(_connString))
                  {
                      using (SqlCommand cmd = new SqlCommand())
                      {
                          cmd.CommandText = "update ref_Accueil set nm_Video=@nm_Video where id_Page=@id_Page";
                          cmd.Parameters.AddWithValue("@id_Page", id);
                          cmd.Parameters.AddWithValue("@nm_Video", bytes);
                          cmd.Connection = con;
                          con.Open();
                          cmd.ExecuteNonQuery();
                          con.Close();
                      }
                  }
              }
              Response.Redirect(Request.Url.AbsoluteUri);
          }
  </code></pre>
  
  <p>I am using Flow Player for my videos.</p>
  
  <p>Here is code in my web.config</p>
  
  <pre><code>&lt;httpRuntime maxRequestLength="1048576" executionTimeout="3600" /&gt;
    &lt;/system.web&gt;
    &lt;system.webServer&gt;
     &lt;security&gt;
        &lt;requestFiltering&gt;
           &lt;requestLimits maxAllowedContentLength="3000000000" /&gt;
        &lt;/requestFiltering&gt;
     &lt;/security&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>When i try to get larger files from database i also got this error on system.dll here is another part of code:</p>
  
  <pre><code>public void ProcessRequest(HttpContext context)
          {
              int id = int.Parse(context.Request.QueryString["id_Page"]);
              byte[] bytes;
              string contentType;
              string _connString = ConfigurationManager.AppSettings["connString"];
              string name;
              using (SqlConnection con = new SqlConnection(_connString))
              {
                  using (SqlCommand cmd = new SqlCommand())
                  {
                      cmd.CommandText = "select id_Page, nm_Video from ref_Accueil where id_Page=@id_Page";
                      cmd.Parameters.AddWithValue("@id_Page", id);
                      cmd.Connection = con;
                      con.Open();
                      SqlDataReader sdr = cmd.ExecuteReader();
                      sdr.Read();
                      bytes = (byte[])sdr["nm_Video"];
                      //contentType = sdr["ContentType"].ToString();
                      //name = sdr["Name"].ToString();
                      con.Close();
                  }
              }
              context.Response.Clear();
              context.Response.Buffer = true;
              //context.Response.AppendHeader("Content-Disposition", "attachment; filename=" + name);
              //context.Response.ContentType = contentType;
              context.Response.BinaryWrite(bytes);
              context.Response.End();
          }
  
          public bool IsReusable
          {
              get
              {
                  return false;
              }
          }
  </code></pre>
  
  <p>while binding </p>
  
  <pre><code>private void BindGrid()
              {
                  string _connString = ConfigurationManager.AppSettings["connString"];
                  using (SqlConnection con = new SqlConnection(_connString))
                  {
                      using (SqlCommand cmd = new SqlCommand())
                      {
                          cmd.CommandText = "select id_Page, nm_Video from ref_Accueil";
                          cmd.Connection = con;
                          con.Open();
                          DataList1.DataSource = cmd.ExecuteReader();
                          DataList1.DataBind();
                          con.Close();
                      }
                  }
              }
  </code></pre>