Increase file upload limit by App.Config C#?

Asked

Viewed 111 times

0

I’m having a problem, we used a file sending system that was done in Webapplication and we will implement it also in a dll. In Webapplication it is possible to configure in Web.config the maximum file size to be sent, using the tags maxRequestLength (IIS <= 6) or maxAllowedContentLength (IIS >=7). But these same tags don’t work on app. Config da dll and hence generates the error below:

System.Net.WebException: Falha na solicitação com status HTTP 404: Not Found. em System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall) em System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)...

Does anyone have any suggestions on how to set the maximum file size by app.Config?

2 answers

0

Can be configured on the web.config of the application that will use this DLL.

I believe you will not be able to configure the application parameters maxRequestLength, maxAllowedContentLength via DLL, as these parameters are global.

0

Good morning, try setting the two variables in the same file:

Adding the variable "maxRequestLenght":

<system.web>
    <compilation debug="true" targetFramework="4.5.2" />
    <httpRuntime maxRequestLength="2000000" targetFramework="4.5.2" />
 </system.web>

Adding the variable "maxAllowedContentLength":

<security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="2000000" />
        </requestFiltering> 
 </security> 

check if you are authorizing access to the method you are accessing:

<httpProtocol>
 <customHeaders>
<add name="Access-Control-Allow-Headers" value="Content-Type" />
<add name="Access-Control-Allow-Methods" value="GET, POST, PUT, DELETE, OPTIONS" />
 </customHeaders>
</httpProtocol>

Browser other questions tagged

You are not signed in. Login or sign up in order to post.