0

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);
7
  • Servers (IIS) normally limit size to around 10M and can't be change in the your client code. Commented Jun 19, 2016 at 13:46
  • There has to be a way... Commented Jun 19, 2016 at 13:51
  • What's the HResult code on your error? Commented Jun 19, 2016 at 14:03
  • In the first method, you are wrapping those tags with <ystem.Webserver tags? Commented Jun 19, 2016 at 14:46
  • Not if there is a limit in the server unless you split file. Commented Jun 19, 2016 at 15:40

1 Answer 1

1

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!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.