Converting json results to a date



var date = new Date(parseInt(jsonDate.substr(6)));



var x = [{
    "id": 1,
    "start": "\/Date(1238540400000)\/"
}, {
    "id": 2,
    "start": "\/Date(1238626800000)\/"

var myDate = new Date(x[0].start.match(/\d+/)[0] * 1);






How to check if IEnumerable is null or empty?

public static class Utils {
    public static bool IsAny<T>(this IEnumerable<T> data) {
        return data != null && data.Any();





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!






Setting IIS and ASP.NET POST Size Request Limits

IIS Setting: Request Limits

The first setting is the IIS Request Limit settings which is installed as part of the Request Filtering IIS Module. IIS Request Filtering is an optional IIS feature, but it is a required install feature when you install ASP.NET in IIS so you can assume it will be installed if ASP.NET is enabled in IIS.

The following sets the max POST buffer size to 500 megs. The value is specified in bytes.

            <requestLimits maxAllowedContentLength="500000000" />

ASP.NET Setting: httpRuntime maxRequestLength

ASP.NET uses the httpRuntime element to control a number of runtime related features including the allowed inbound request length. The inbound data size is checked very early in the request cycle and makes a request fail immediately.

        <httpRuntime maxRequestLength="500000000"  executionTimeout="120" />



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,




Check for Balanced Parenthesis in a String


public static bool IsBalanced(string input)
        Dictionary<char, char> bracketPairs = new Dictionary<char, char>() {
            { '(', ')' },
            { '{', '}' },
            { '[', ']' },
            { '<', '>' }

        Stack<char> brackets = new Stack<char>();

            // Iterate through each character in the input string
            foreach (char c in input)
                // check if the character is one of the 'opening' brackets
                if (bracketPairs.Keys.Contains(c))
                    // if yes, push to stack
                // check if the character is one of the 'closing' brackets
                    if (bracketPairs.Values.Contains(c))
                    // check if the closing bracket matches the 'latest' 'opening' bracket
                    if (c == bracketPairs[brackets.First()])
                        // if not, its an unbalanced string
                        return false;
                    // continue looking
            // an exception will be caught in case a closing bracket is found, 
            // before any opening bracket.
            // that implies, the string is not balanced. Return false
            return false;

        // Ensure all brackets are closed
        return brackets.Count() == 0 ? true : false;