0

I want to upload photos to ASP.NET Web API but return error from some photos uploading. I successfully upload to file size 17002 and smaller but I don't upload file size 17345 and bigger. Note: EnableCors on Web API and maxRequestLength="307200" and maxAllowedContentLength="314572800" all of OK. Error (For example when I tried to upload to a photo file size 17345):

XMLHttpRequest cannot load http://localhost:42658/api/MyApi/UploadFile. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. The response had HTTP status code 500.

I'm using IIS7. Anyone have a solution for this?

2 Answers 2

1

i have a same problem, and i found that have a two tags <httpRuntime> like:

`<httpRuntime  maxRequestLength="1048576" executionTimeout="3600" />
<httpRuntime targetFramework="4.6.1"/>`

And the problem was solved that I united them into one like this:

<httpRuntime targetFramework="4.6.1" maxRequestLength="1048576" executionTimeout="3600" />
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for this - I had the same issue and somehow failed to realize this same (obvious) mistake.
0

Did you try like below ?

<system.webServer>
   <security>
      <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
   </security>
 </system.webServer>

1 Comment

Thanks for answer. Yes, I did try and I tried again after your answer but doesn't work.

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.