The request body did not contain the specified number of bytes. Got 0, expected xxx – Internet Explorer Issue

When you try to re-POST subsequent requests from Internet Explorer browser it only sends only the header data is posted. As a result you will receive error in response – The request body did not contain the specified number of bytes. Got 0, expected xxx. There is already a Hotfix available at Microsoft Knowledge Base

General Repro Steps –

  1. For every first XMLHttpRequest, a keep alive connection (TCP Connection) is created which is used by any subsequent request. If the connection is forcibly closed by the browser, then browsers will try to create a new connection by resubmitting the request.
  2. For GET Requests it will work without any issues. But for POST it will only send Request Headers and not the body in Internet Explorer. That’s why you will receive error – The request body did not contain the specified number of bytes. Got 0, expected xxx.
  3. As a solution either install above mentioned Hotfix or Use NEW unique URL by adding TimeStamp to URL to avoid any re-POST request.

For e.g.

var urlToPost = "ajaxUrlToPost.svc?stamp=' + new Date().getTime();

SharePoint 2010/2013 Date Comparison in different Time Zones

Working with DateTime in SharePoint is always tricky since it stores values internally in UTC and when we tried to access it in CSOM or SOM in different Time zone we have to be very careful while filtering on Created, Modified Date columns.

Time Zone plays very crucial roles in any Date Time difference calculation. When we do difference in two date times, it must be in same Time Zone offset otherwise the result will never be correct. Here, TimeZoneInfo class plays main role. To get specific time zone details we have to use TimeZoneInfo.FindSystemTimeZoneById method which will take input of Zone Id. All available Time Zone Id’s can be found at MSDN

To explain this problem lets take a example that we need to find all SharePoint List items which was created in last 5 minutes.

First we will retrieve all Items from a List which is created Today. We will use CAML Query to get these items.

// Store result in temporary Table
DataTable dataResult = new DataTable();

//Get List Data
SPWeb sbWeb = SPContext.Current.Site.RootWeb;
SPList list = sbWeb.GetList(“MyCustomList”);
SPQuery listQuery = new SPQuery();

// Get items for todays date
listQuery.Query = “<Where><Eq><FieldRef Name=’Created’ /><Value Type=’DateTime’><Today /></Value></Eq></Where>”;
SPListItemCollection items = list.GetItems(listQuery);


Iterate through each list item and perform Date time conversion.


foreach (SPListItem item in items)
if (item[“Title”] != null && item[“ID”] != null)

// Get UTC Now Date Time
DateTime utcNowDate = new DateTime(DateTime.UtcNow.Ticks, DateTimeKind.Utc);

// Find the Server Time Zone Info which is configured under Central Administration -> Web Application -> General Settings
TimeZoneInfo timeZoneInfo = TimeZoneInfo.FindSystemTimeZoneById(“Pacific Standard Time”);

// Convert UTC Now Date Time to server’s Time Zone i.e. into Pacific Standard Time in our example.
DateTime convertedUtcNowDateTime = TimeZoneInfo.ConvertTimeFromUtc(utcNowDate , timeZoneInfo);

// Find the Date time difference into TimeSpan
TimeSpan diffResult = convertedUtcNowDateTime – Convert.ToDateTime(item[“Created”]);

// Create 5 Minutes Time Span object
TimeSpan fiveMinutesSpan = new TimeSpan(0, 5, 0);

// Compare method will return -1 if first time interval is shorter than second and return 0 if both time interval are equal. Read more about this at
int result = TimeSpan.Compare(diffResult, fiveMinutesSpan);

// If result is 0 Or -1 it means items is created in last five minutes.
if (a < 1) { DataRow row = dataResult.NewRow(); row["Title"] = item[SPBuiltInFieldId.EncodedAbsUrl].ToString(); row["ID"] = item[ColumnName.ReportUrl].ToString(); data.Rows.Add(dr); } } } [/csharp] Resulting DataTable will have the filtered result. Sharing is Caring 🙂

jQuery based Resource Localization

Create client side (JavaScript) based Resource Localization in any web application. Extremely light-weight library, just 3KB (Minified) and 8KB(Debug) version.

Implementing client side localization into any web application is always challenge. Most of web technologies provide localization using server-side technologies. For e.g. .Net application uses Resources Files(.resx) to implement localization into globalization application.

Nowadays world is extensively moving towards Asynchronous development models like AJAX / SPA. Several frameworks, libraries are already available on the web. To access these server side resources requires custom REST services / handlers to be additionally implemented into the host application.

This plugin makes life easier where you can manage all your localized resources into plain Text or JavaScript file. Based on current culture provided to this plugin, it loads associated resource entries for use. To enhance performance it Cache data for subsequent Initialization calls. So now no more server side development required for managing localization. It can be used in any web applications like SharePoint On-Premise / Online, Php, ASP.Net MVC, JAVA and many more as long as these technologies supports JavaScript.

Download Pugin from Github Github.

Install via Nuget Package.

JQuery Culture Information Plugin

Accessing Culture Information for all available cultures in JavaScript is always difficult and most of the web developer has to search on internet for this information. There may be several options available to fetch this information into Server-side technologies like ASP.Net, JAVA, PHP, and etc. But in JavaScript it is very difficult to find this information at one place.

To solve this problem, I have created small jQuery plugin which will give you this information at one place. You can search for Culture information by LCID (for e.g. 1033) or by Culture Name (for e.g. en-US), which will return you JSON Object. This plugin can be used in any of your favorite application which supports JavaScript.

  1. Refer to the Github Project JQuery Culture Information Plugin
  2. Install via the NuGet Package Install-Package PritamBaldota.JqueryCultureInfo

Sharing is Caring 🙂

Free MP3 Downloader

Downloading MP3 songs is always difficult and one has to search several blogs to do this activity. Still we have limitation of time to search and download songs.

I have created small tool for my Wife so she  doesn’t need to worry about searching songs to play when offline. Sharing the same tool for your use. This is beta and still some enhancements required. Please drop your comments so I can improve it in next release.

Click Free MP3 Downloader to Download the tool.

On Install click Yes to download album list from server. It will take few sections to show all albums. On subsequent use it will not download list. You can refresh list on demand. Once list is downloaded you can search whatever album you want. Check the album(s) you would like to download. Set the target folder and Click Start Download in background.


Associate Custom Content Type with SharePoint 2010/2013 List Or Library using PowerShell

To automate deployment in SharePoint 2010/2013 on-premise solution, we have to use PowerShell. One of the deployment activity is creating SharePoint Custom Lists/Libraries and associating them with custom created content types. In this article we will be focusing only how to add/remove content types from the List/Library.

To add content type follow below steps –

  • Get Reference to Site collection and root web to get the content types.


$siteRef = Get-SPSite http://domain/site
$rootWebRef = $siteRef.RootWeb


  • Get the target web reference to which content type will be added for List/Library.

$web = Get-SPWeb http://domain/site/web

  • Get the reference to target list / library

$listRef = $web.Lists[“List Title”]

  • Enable the management of content type for this list/library.


$listRef.ContentTypesEnabled  = $true


  • Get the deployed Content Type reference from root web which will be added to the target list.

$targetContentType= $rootWebRef.ContentTypes[“CustomContentType”]

  • Check if Content is already exists from ContentTypes collection of a List. If not found then add the content type to the list.

$contentTypeExist = $listRef.ContentTypes[$contentType.Name]
if($contentTypeExist -ne $null)

To delete content type follow below steps –

To delete content type association from list, we have to get the reference of associated content type and pass the Id of content type to Delete method on ContentTypes collection.


$contentTypeExist = $listRef.ContentTypes[$contentType.Name]



This is how the complete code will look like –


$siteRef = Get-SPSite http://domain/site
$rootWebRef = $siteRef.RootWeb
$web = Get-SPWeb http://domain/site/web

$listRef = $web.Lists[“List Title”]
if ($listRef -ne $null)
$listRef.ContentTypesEnabled  = $true
$targetContentType = $rootWebRef.ContentTypes[$contentType.Name]
if($targetContentType -ne $null)
$contentTypeExist = $listRef.ContentTypes[$contentType.Name]
if($contentTypeExist -ne $null)
Write-Host “Adding Content Type – ” $targetContentType.Name -ForegroundColor Green
Write-Host ”  Content Type already exists – ” $targetContentType.Name -ForegroundColor Green


Happy Coding 🙂

Understanding Features and Feature Scope in SharePoint 2010

What is SharePoint 2010 Features?

  • SharePoint Features is part of Packaging and Deployment in SharePoint 2010
  • Features make it easier to activate or deactivate functionality in the course of a deployment, and administrators can easily transform the template or definition of a site by simply toggling a particular Feature on or off in the user interface.
  • Features are stored under %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\TEMPLATE\FEATURES
  • The Feature subfolder includes a Feature.xml file and any number of supporting element files.
  • Features can be installed/uninstalled using STSADM tool, SharePoint Management Shell, Or Object Model.

Understanding Feature Scope

  • Sharepoint 2010 Can be scoped to Farm, Web Application, Site Collection, and Web Site level.
  • Feature Scope id defined by Scope attribute in feature.xml
  • Sample Feature will look like this

<Feature Id=”F62C96CF-79FD-44be-8882-E9BFBD199184″

Title=”Feature Title”

Description=”Feature Description”





Web Site scoped Feature (Scope=”Web”)

  • Web Site Scoped feature can be activated at individual Web site level.
  • List Instances, Event Receivers, Custom Actions etc are the custom elements for Website scope features.
  • It can be activated by STSADM command like ” stsadm “o installfeature “name FeatureFolderName “url http://sharepointserver/site/subsite
  • Alternatively open site features page by site actions -> site settings -> modify all site settings ->site features and click activate.

Site Collection scoped Feature (Scope=”Site”)

  • Site Collection Scoped feature can be activated at the site collection level.
  • It can contains item that can apply to Site Collection as a whole like content types that are shared across the site collection, as well as items that can be activated per site for e.g. List Instances, Event Receivers, Custom Actions etc
  • It can be activated by STSADM command like ” stsadm “o installfeature “name FeatureFolderName “url http://sharepointserver/site/sitecollectionname
  • Alternatively open site features page by site actions -> site settings -> modify all site settings ->site features and click activate.

Web Application scoped Feature (Scope=”WebApplication”)

  • Web Application Scoped feature can be activated at the Web application level.
  • It can contains item like administrative web application links, delegate control registrations, document forms registration etc.
  • It can be activated by STSADM command like ” stsadm “o installfeature “name FeatureFolderName “url http://sharepointserver
  • Alternatively open Manage Web Application Features from Central Administrator Central Administrator -> Application Management -> Manage Application Features and click activate.

Farm scoped Feature (Scope=”Farm”)

  • Farm Scoped feature can be activated at the Farm level.
  • It can contain number of element like application logic etc which can be applicable anywhere within deployment. It contacts links to /_layouts pages and files, /_admin pages etc.
  • It can be activated by STSADM command like ” stsadm “o installfeature “name FeatureFolderName
  • Alternatively open Manage Farm Features from Central Administrator Central Administrator -> Operations -> Manage Application Features and click activate.
  • Farm scope feature will be activated automatically once it is installed on server.


Web Application Limits and Boundaries in SharePoint 2010

This article describes Microsoft SharePoint Server 2010 software boundaries and limits. These include the following:

Exceeding any of Supported limits may cause Performance Issue in SharePoint 2010.

  • Maximum size of Document in SharePoint 2010 is 2GB
  • Default Threshold of Document Size in SharePoint 2010 is 50MB
  • 250000 maximum recommended number of site collections per Web application is supported in SharePoint 2010
  • 300 Content Databases Per Web Application are supported
  • Maximum 5 Zones per Web Application. (Default, Intranet, Internet, Extranet, and Custom. Zones limit defined for farm is hard-coded.
  • Managed paths are cached on the Web server, and CPU resources are used to process incoming requests against the managed path list. Maximum 20 number of Managed Path per Web Application supported.
  • Maximum 300 MB Solution Cache Size per Web Application. The solution cache allows the InfoPath Forms service to hold solutions in cache in order to speed up retrieval of the solutions.



What is AJAX

What is AJAX ?

  • AJAX is Asynchronous JavaScript And XML.
  • The XmlHttpRequest is an actual object which works behind the scene.
  • Ajax implementation uses JavaScript functions to call methods from a webservice, webpage request in response to get response.
  • Response data is parsed using DOM.
  • Asynchronous data retrieval using XmlHttpRequest

Advantages of AJAX

  • Reduce the traffic travels between the client and the server.
  • Response time is faster so increases performance and speed.
  • You can use JSON (JavaScript Object Notation) which is alternative to XML. JSON is key value pair and works like an array.
  • You can use Firefox browser with an add-on called as Firebug to debug all Ajax calls.
  • Ready Open source JavaScript libraries available for use – JQuery, Prototype, Scriptaculous, etc..
  • AJAX communicates over HTTP Protocol.

Disadvantages of AJAX

  • It can increase design and development time
  • More complex than building classic web application
  • Security is less in AJAX application as all files are downloaded at client side.
  • Search Engine like Google cannot index AJAX pages.
  • JavaScript disabled browsers cannot use the application.
  • Due to security constraints, you can only use it to access information from the host that served the initial page. If you need to display information from another server, it is not possible within the AJAX.

Garbage Collection in .NET

Garbage Collection in .NET

Garbage Collector provide automatic Memory Management in .NET. It is Component of .net CLR (Common Language Runtime). Follow are the advantages of Garbage Collection –

  • It allocates memory objects on heap efficiently.
  • Develop application without worrying about releasing of memory.
  • Reclaims object that are no longer in use, clear their memory and keep it available for future memory allocations.
  • Memory Safe as cannot direct access memory of other objects.

Fundamentals of Memory –

  • Each process has its own, separate virtual address space; on 32-bit computers each process has a 2-GB user-mode virtual address space.
  • Garbage collector is responsible for Allocation and frees virtual memory on Managed Heap.
  • Virtual memory can be in three state – FREE , RESERVED, COMMITTED
  • We can run out of memory if run out of virtual address space to reserve or physical space to commit.

When Garbage Collection runs-

  • System has low physical memory
  • The memory that is used by allocated objects on the managed heap surpasses an acceptable threshold. This means that a threshold of acceptable memory usage has been exceeded on the managed heap. This threshold is continuously adjusted as the process runs.
  • The GC.Collect method is called. In almost all cases, you do not have to call this method, because the garbage collector runs continuously. This method is primarily used for unique situations and testing.

What is Managed Heap?

  • Garbage Collector allocates segment of memory for objects which is called Managed Heap.
  • Each managed process has managed heap.
  • Win32 VirtualAlloc and VirtualFree functions called by garbage collector to reserve or release segment of memory.
  • After triggering Garbage Collector, it reclaims the memory occupied by dead objects and compact live objects so they live together. This process will make heap smaller.
  • Heap can be considered as : Large Object Heap and Small Object Heap
  • Objects with size 85000 bytes and larger will go on Large Object Heap.


  • Heap is organized into generations which can easily handle long live objects and short lived objects.
  • There are three generations – Generation 0 , Generation 1, Generation 2
  • Generation 0 – This is youngest generation for newly created objects. Garbage collector reclaims memory from this Generation most frequently. For e.g. Temporary variables, new objects
  • Generation 1 – Short lived objects are resides in this generation. As soon as Garbage collector starts reclaiming memory, objects from Generation 0 will move to Generation 1 if they are still in use.
  • Generation 2 – Long lived objects are resides in this generation. For e.g. Static variables.

You can find detailed article on –