• How to used localStorage and sessionStorage of HTML5 to store data in ASP.NET MVC?

    by  • October 28, 2015 • Microsoft .NET Framework, Microsoft ASP.NET, Microsoft ASP.NET MVC • 0 Comments

    Often, many developers use localStorage and sessionStoarage of HTML5 to store data in ASP.NET. Local Storage improves the performance of our data-driven ASP.NET applications by caching data in the browser persistently. Local Storage saves data for a long time. The localStorage object stores the data with no expiration date. The data will not be deleted when the browser is closed, and will be available the next day, week, or year. In localStorage we can store up to 10MB data. We can post localStorage data to server via Ajax Request.

    The sessionStorage object is equal to the localStorage object, except that it stores the data for only one session. The data is deleted when the user closes the specific browser tab.

    This article will explain to you how to used localStorage and sessionStorage of HTML5 to store data in ASP.NET MVC.


    The Model comes to a simple class containing raw data. The fields that we need are ID, EmployeeName, EmployeeAge and EmployeeNumber. The source code of the model class is shown below:


    Since there is no server-side processing, the controller class is also fairly simple and it practically does nothing. The controller class used in the example is shown below:


    The View used in the example is shown below:

    Best WordPress Themes and Plugins with Great Team and Support!

    Avatar of Abdul Rehman


    Abdul Rehman writes on .NET technologies at GetCodeSnippet.com. GetCodeSnippet.com provides you high quality Microsoft .NET development related articles, tutorials and sample code for ASP.NET, C#, VB.NET, AJAX, WCF, WPF, Web Services, Windows Services, SQL Server and other technologies.


    Leave a Reply