ASP.NET State Service Tutorial : Implementing State Server Session In ASP.NET

In this article, we will show you how can we implement “state server” session state management technique in

Bellow are steps for implementing “State Server” session management technique.

  • Add configuration in of Web.Config.

<sessionState mode=”StateServer” stateConnectionString=”tcpip=″/>

Here, mode=”StateServer” means session mode is “State Server”. Other modes are inproc, SQL server & custom.
stateConnectionString=”tcpip=″ means session state windows service is running on (this is same machine where I am running my application as well as service. If you are running windows service on other machine then put that machines IP) on port 42424 (this is default port on which service runs. This can bechanged in registry).

  • Starting “StateServer” windows service

Go to services (gor to Run => services.msc) & find “ASP.NET State Service”.

Change startup type of“ASP.NET State Service”to “Automatic” & start the service.

This configuration is enough if you have state server on same machine.

You might get bellow error if you are using other machine for storing state.

“Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either ‘localhost’ or ’′ as the server name.”

To solve this error follow bellow steps

  • Go to machine where windows service is running.
  • Go to registry (Go to Run => regedit)
  • Go to this path -> “HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection”

  • Change Value of parameter “AllowRemoteConnection” from 0 to 1.

Here you also change port number as well by changing Value of “PORT” parameter.

  • Now restart windows service.

Hope fully after doing this error will be gone & you will be able to implement “StateServer” session management technique successfully in ASP.NET. revolutionized hosting with Plesk Control Panel, a Web-based interface that provides customers with 24×7 access to their server and site configuration tools. Plesk completes requests in seconds. It is included free with each hosting account. Renowned for its comprehensive functionality – beyond other hosting control panels – and ease of use, Plesk Control Panel is available only to HostForLIFE’s customers. They offer a highly redundant, carrier-class architecture, designed around the needs of shared hosting customers.

ASP.NET MVC 6 Tutorial :: How to Search Record in MVC With Ajax and jQuery?

Today’s turotial is about how to search record in MVC with Ajax and jQuery. This code will filter out all matching records group by table column name.

First thing that you should do is create an empty ASP.NET MVC project. Now, add two class to your model. Employee and DemoContext and write the following code:

namespace SearchingDemo.Models
public class Employee
public int Id { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string Position { get; set; }
namespace SearchingDemo.Models
public class DemoContext : DbContext
public DbSet<Employee> Employees { get; set; }

Add a Home Controller. Now, Add index Action to controller. and create corresponding view.

public ActionResult Index()
return View();

Now, write the following code to Index View.
<link href="~/Content/Style.css" rel="stylesheet" />
<script src="~/Content/jquery-2.1.1.min.js"></script>
<script src="~/Content/CustomJs.js"></script>
<h2>Seaching Demo</h2>
<div class="divFind">
<input type="text" id="txtSearch" />
<input type="button" id="btnSearch" value="Seach" />
<div id="divList">

Write the .JS code for click event on seach button to get filtered result. add following .JS code.

$(document).ready(function () {
$('#btnSearch').on('click', function () {
var getkey = $('#txtSearch').val();
type: 'POST',
contentType: 'application/json; charset=utf-8',
url: 'Home/Search',
data: "{ 'searchKey':' " + getkey + "' }",
success: function (data) {
error: function (data) {
alert('Error in getting result');
function BindData(data) {
var ulList = '<ul>';
var resultType = ["FirstName", "LastName", "Position"];
$.each(data, function (i, d) {
ulList += '<li class="SeachType">' + resultType[i] + '</li>';
if (d.length > 0) {
$.each(d, function (key, value) {
ulList += '<li>' + value.FirstName + ' - ' + value.LastName + ' - ' + value.Position + '</li>'
} else {
ulList += '<li><span class="red">No Results</span></li>';
ulList += '</ul>'

Javascript code calling search function, which is written in controller. Add search function to your controller.

public JsonResult Search(string searchKey)
DemoContext dbObj = new DemoContext();
var getKey = searchKey.Trim();
var getFirstName = dbObj.Employees.Where(n => n.FirstName.Contains(getKey)).ToList();
var getLastName = dbObj.Employees.Where(n => n.LastName.Contains(getKey)).ToList();
var getPostion = dbObj.Employees.Where(n => n.Position.Contains(getKey)).ToList();
IList<IList<Employee>> getTotal = new List<IList<Employee>>();
int count = getTotal.Count();
return Json(getTotal);
} ASP.NET MVC 6 Hosting is European Windows Hosting Provider which focuses on Windows Platform only. We deliver on-demand hosting solutions including Shared hosting, Reseller Hosting, Cloud Hosting, Dedicated Servers, and IT as a Service for companies of all sizes. We have customers from around the globe, spread across every continent. We serve the hosting needs of the business and professional, government and nonprofit, entertainment and personal use market segments.