Request Entity Too Large Exception in Web API

The UploadReadAheadSize property establishes the number of bytes a Web server will read into a buffer and pass to an ISAPI extension. This occurs once per client request. The ISAPI extension receives any additional data directly from the client. The range is from 0 to &HFFFFFFFF (4 GB).

For more details on this property please check the URL –


To navigate to this setting, use the following steps:

  • Launch “Internet Information Services (IIS) Manager”
  • Expand the Server field
  • Expand Sites
  • Select the site your application is in.
  • In the Features section, double click “Configuration Editor”
  • Under “Section” select: system.webServer>serverRuntime


For my case, customer had maximum file size less than 50 MB, so we set it to 52428800 i.e. 50 MB.

Please note that the value is in Bytes.


This resolved the issue for us and file uploads and downloads worked fine.


I hope this helps!







Web API and C# out Values


public IHttpActionResult GetResponse(int id)
    int outputInt;
    string outputString;

    YourMethodWithOutParameters(id, out outputInt, out outputString);

    return Ok(new
        Id = id,
        OutputInt = outputInt,
        OutputString = outputString,




debug web service project in same solution as web site project

In your solution file, click properties go to the Startup project node (if it is not already selected)

Next select Multiple startup projects. Select your website and your webservice and in the Action column make sure both of them have “Start” selected.

Now when you debug your website and put a break point in you webservice it should hit the break point.

Thats all i can think of for your problem. Hope it helps.



Web API error: The ‘ObjectContent`1’ type failed to serialize the response body for content type ‘application/xml

Add following liners in dbcontext constructor

public DbContext() // dbcontext constructor
            : base("name=ConnectionStringNameFromWebConfig")
     this.Configuration.LazyLoadingEnabled = false;
     this.Configuration.ProxyCreationEnabled = false;

Another change has to do for App_Start / WebApiConfig.cs class in my MVC Web API project

var json = config.Formatters.JsonFormatter;
json.SerializerSettings.PreserveReferencesHandling = Newtonsoft.Json.PreserveReferencesHandling.Objects;