Click here to Skip to main content
11,922,641 members (56,670 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


16 bookmarked

(413) Request Entity Too Large

, 13 Jan 2013 CPOL
Rate this:
Please Sign up or sign in to vote.
A solution to the problem.

Recently I worked with a WCF web service which is hosted in IIS7, and I used one of the service methods to send a byte array which contains a picture. This works well with small size images, but when I’m trying to upload a larger picture, the WCF service returns an error: (413) Request Entity Too Large. Same error I got a month ago when I was developing an ASP.NET web application which is hosted on IIS 7 over SSL. In that case, there was no file upload on the page. It occurred when I’m accessing the web pages which are having a grid view control with large number of paging. The same pages worked fine on HTTP but not on HTTPS. In both scenarios, I Googled and found out different solutions.

1. uploadReadAheadSize

In the second scenario, the error occurred because of the size of the page, it is very large and it caused to request entry body become larger when you submitting the page.

Basically, what happens is if you have a website with SSL and "Accept Client Certificates" enabled HTTP requests are limited to the UploadReadAheadSize of the site. To resolve this, you have to increase the UploadReadAheadSize. (Default size 48kb)

appcmd.exe set config -section:system.webserver/serverruntime /uploadreadaheadsize: 1048576 /commit:apphost

2. maxReceivedMessageSize

WCF by default limits messages to 64KB to avoid DOS attack with large message. By default, it sends byte[] as base64 encoded string and it increases the size of the message (33% increase in size). There for if the uploaded file size is ~larger than 48KB then it raises the above error. (48KB * 1.33 = ~64KB) (NB. you can use MTOM – Message Transmission Optimization Mechanize to optimize the message)

By modifying the "maxReceivedMessageSize" in the Web.config file to accept large messages, you can solve this issue.

      <binding maxReceivedMessageSize="10485760">
        <readerQuotas ... />


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Tharaka MTR
Technical Lead Eyepax IT Consulting (Pvt) Ltd.
Sri Lanka Sri Lanka
Having more than 9 year hands-on industry experience in software development
Responsible for designing, implementing and managing complex software systems with stringent up-time requirement.

Visit my blog

You may also be interested in...

Comments and Discussions

QuestionHello Tharaka MTR, I still the problem. 413 Request Entity Too Large Pin
Member 1098845319-May-15 5:33
memberMember 1098845319-May-15 5:33 
QuestionStill got the problem Pin
Member 1054058626-Aug-14 1:14
memberMember 1054058626-Aug-14 1:14 
QuestionI already stated in the article but I still have the error 413 Pin
raijuli16-Jul-14 7:45
memberraijuli16-Jul-14 7:45 
AnswerRe: I already stated in the article but I still have the error 413 Pin
Tharaka MTR19-Jul-14 2:08
professionalTharaka MTR19-Jul-14 2:08 
QuestionStill error Pin
rk_prabakar7-Aug-13 1:21
memberrk_prabakar7-Aug-13 1:21 
AnswerRe: Still error Pin
Tharaka MTR7-Aug-13 2:01
professionalTharaka MTR7-Aug-13 2:01 
GeneralRe: Still error Pin
rk_prabakar7-Aug-13 19:51
memberrk_prabakar7-Aug-13 19:51 
GeneralRe: Still error Pin
Tharaka MTR9-Aug-13 1:16
professionalTharaka MTR9-Aug-13 1:16 
Answer413 error solution work for me Pin
rajkiran3-Aug-13 3:23
memberrajkiran3-Aug-13 3:23 
GeneralRe: 413 error solution work for me Pin
Tharaka MTR4-Aug-13 4:35
professionalTharaka MTR4-Aug-13 4:35 
Questionyou saved my time Pin
Member 80626319-Jul-13 2:37
memberMember 80626319-Jul-13 2:37 
AnswerRe: you saved my time Pin
Tharaka MTR10-Jul-13 0:09
professionalTharaka MTR10-Jul-13 0:09 
GeneralMy vote of 4 Pin
Marco Alessandro Bertschi14-Jan-13 4:16
memberMarco Alessandro Bertschi14-Jan-13 4:16 
GeneralRe: My vote of 4 Pin
Tharaka MTR14-Jan-13 6:19
memberTharaka MTR14-Jan-13 6:19 
GeneralMy vote of 3 Pin
arbinda_dhaka13-Jan-13 10:17
grouparbinda_dhaka13-Jan-13 10:17 
GeneralRe: My vote of 3 Pin
Tharaka MTR13-Jan-13 16:35
memberTharaka MTR13-Jan-13 16:35 
GeneralMy vote of 5 Pin
Thornik8-Jan-13 6:34
memberThornik8-Jan-13 6:34 
GeneralRe: My vote of 5 Pin
Tharaka MTR13-Jan-13 16:36
memberTharaka MTR13-Jan-13 16:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.151125.1 | Last Updated 13 Jan 2013
Article Copyright 2013 by Tharaka MTR
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid