Unable to upload 2gb file
Hi,I am trying to upload 2 GB file on to a file location.
I have the following code in .cs file
if (FileUpload1.HasFile && FileUpload1.FileBytes.Length < 2147483)
{
try
{
string filename = Path.GetFileName(FileUpload1.FileName);
string SaveLocation = Server.MapPath("UploadedFiles") + "\\" + filename;
FileUpload1.PostedFile.SaveAs(SaveLocation);
Response.Write("The file has been uploaded.");
}
catch (Exception ex)
{
throw ex;
}
following settings in web.config file:-
<configuration>
<system.web>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.5">
<assemblies>
<add assembly="System.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" maxRequestLength="2097152" executionTimeout="32247"/>
</system.web>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483648" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
still iam getting the following error:-
Exception of type 'System.OutOfMemoryException' was thrown.
Let me know if anyone has solution for this problem.