Reputation: 25
hello i try to download files larger than 10M but files not downloaded
only pdf files are opend and other extensions (downloaded 0 bytes)
here is my code
public ActionResult DownloadFile(string fileName)
{
string path = Path.Combine(Server.MapPath("~/Files/PageItem/"), fileName);
byte[] fileBytes = new byte[0];
if (System.IO.File.Exists(path))
{
fileBytes = System.IO.File.ReadAllBytes(path);
}
return File(fileBytes, System.Net.Mime.MediaTypeNames.Application.Octet, fileName);
}
and here is my Webconfig file
<system.web>
<customErrors mode="Off" />
<compilation targetFramework="4.5" debug="true"/>
<httpRuntime targetFramework="4.5" maxRequestLength="1048576" executionTimeout="3600"/>
</system.web>
note that i checked uploded files at server and they are correct size and format what is wrong with me ??? and why only large pdf files that opens and no other extension
Upvotes: 1
Views: 2763
Reputation: 2541
By default IIS file size limit is 4MB.
try to add this to your web.config
(the example to allow 20MB files)
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="20971520" />
</requestFiltering>
</security>
edit1: You might check the request length size as well
<configuration>
<system.web>
<httpRuntime executionTimeout="110" maxRequestLength="20000" />
</system.web>
</configuration>
Upvotes: 1