Reputation: 1181
I'm trying to increase maximum upload limit size in my .NET application... Current one is 4MB and I'd like to increase it to 25 MB ...
What I have tried so far (modifying web.config file):
<security>
<requestFiltering>
<!-- maxAllowedContentLength, for IIS, in bytes -->
<requestLimits maxAllowedContentLength="15728640" ></requestLimits>
</requestFiltering>
</security>
And:
<system.web>
<httpRuntime maxRequestLength="25000" />
</system.web>
The second method gives me following error:
HTTP Error 500.19 - Internal Server Error
The requested page cannot be accessed because the related configuration data for the page is invalid.
Without any of these method I'm getting this error:
Maximum request length exceeded.
I'm using .NET Web Forms... And my IIS version is 8 (or above I believe)...
Can someone help me out with this ?
string fileName = fileLanguage.PostedFile.FileName;
using (var fileStream = File.Create(Server.MapPath("../languages/") + fileName))
{
fileLanguage.PostedFile.InputStream.Seek(0, SeekOrigin.Begin);
fileLanguage.PostedFile.InputStream.CopyTo(fileStream);
}
Language language = new Language();
language.Name = txtLanguageName.Text;
language.Path = fileName;
ServiceClass.InsertLanguage(language);
Upvotes: 0
Views: 4765
Reputation: 1181
I've found the reason why the method #2 didn't work... Turns out I had a folder from which I was uploading the files?? And that folder had its own config inside it self... All I had to do was to insert this into my folder's web.config file like following:
<?xml version="1.0"?>
<configuration>
<system.web>
<authorization>
<deny users="?"/>
</authorization>
<httpRuntime executionTimeout="100000" maxRequestLength="214748364" />
</system.web>
</configuration>
Note you can limit the file size to something about ~25-30 MB, since it's not recommended to allow users or anyone else to upload large files onto your server.
Cheers!
Upvotes: 1