February 3, 2018

Session Storage - a client-side state management technique

In web application development, storing values in client side has limited options and those have their own limitations. For example, it can be hard to store data manipulated using web scripting languages as jQuery, JavaScript etc. Most of the time user prefer to store such data in session variable, to avoid overhead calculation of data or reading it again from repository.

HTML5 has introduced additional client-side state management variable called “session storage”. This is supportable to the browser which does support HTML5, as IE 8/above, Firefox 3/above, Safari 4/above etc. Session storage can store string type of variable in client side in simple and easy steps. Reading and writing in to session storage is quite simple. An example is shown below, please note the code is written using jQuery.

Set a value in session storage:
sessionStorage.setItem("name", “Navin Pandit”);

Read a value from session storage:


Store an object data

To store an object data in session storage, you need to convert it in to string type. An simple example given below, shows to store an object data.

var obj = {“name”:”Navin Pandit”, “country”: “India”, “url”:”navinpandit.blogspot.in”};
sessionStorage.setItem("myObj", JSON.stringify(obj));

var obj = JSON.parse(sessionStorage.getItem("myObj"));

January 27, 2017

Failed to call controller method using AJAX in MVC 4 when deployed in IIS Server

Have you ever faced this issue in ASP.NET MVC? I found this issue after deploying my MVC application in IIS server, I shocked as it was working fine in local system but in hosting server it was not. Tried to search solution over the net but non of the solution worked for me. Finally I changed the URL verb and it was resolved. The detail of error is given below, hope it will be useful for someone.


Failed to load data..{"readyState":4,"responseText":....some HTML tag..\r\n \r\n The resource cannot be found.\r\n \r\n


Solution is pretty simple, use "../" in your SRC instead of "~" symbol.

Updated on https://www.codeproject.com/Answers/790566/Failed-to-call-controller-method-using-AJAX-in-MVC?cmt=914340