Thursday, 25 July 2013


NHibernate Pitfalls:

Wednesday, 17 July 2013

Web API Formatters

     public static class FormattersConfig
        public static void Register(HttpConfiguration config)
            #region Json Formatter

            // Default formatter is Json Formatter
            // Default Json Formatter uses Json.Net
            // You can change the Json Formatter to use DataContractJsonSerializer
            config.Formatters.JsonFormatter.UseDataContractJsonSerializer = true;

            // How to Remove?


             #region Xml Formatter

            // Default Xml Formatter uses DataContractSerializer
            // You can change the Xml Formatter to XmlSerializer
            config.Formatters.XmlFormatter.UseXmlSerializer = true; 

            // How to Remove?


            #region Custom Formatter, custom Xml, comma delimited values, etc

            // Create CustomFormatter class which extends MediaTypeFormatter class.
            // Then call config.Formatters.Add(new CustomFormatter());


Friday, 12 July 2013


You can access the presentation at:

The Screencast is at:

You should be able to run on your pc without any problems (this is the code that accompanies the screencast)

The rest of the source code is at: this requires mongodb and nodejs to run. You can install these on your pc but it requires a bit of work.

Friday, 5 July 2013

Web API and Tracing

We wrote our custom request/response logger for our Web API project so that we can analyze and monitor all the inputs and outputs whereas there seems to be a built-in tracing feature in the Web API:

I'll try it for my next Web API project!

Tuesday, 2 July 2013

How to control the Request Size and Execution Timeout

Limiting the Request

You can apply the below limits on the request:

  • Request size; default is 28.6MB in IIS 7.0 and 4MB in IIS 6.0. Please see below.
  • Request header size
  • Url length; default is 4KB
  • Query string length; default is 2KB

Request Size

If content size exceeds 1024 bytes then throw 404.13 error:


IIS 6.0:


IIS 7.0:


Request TimeOut



Max Response Size

• Response size by default doesn’t have a limit from the server point of view.

• The client, however, can limit the response size by setting “content-length” in the request header.

• If very large data required, we should be considering compressing the data or returning binary data. How large is very large?! Perhaps above 50MB.