Showing posts with label AppFabric. Show all posts
Showing posts with label AppFabric. Show all posts
1

Windows AppFabric Caching for SessionState Provider ASP.NET

Using Windows Server AppFabric Caching Session State Provider For Asp.Net 3.5 And 4.0. In ASP.NET 4 we have following options to choose and use for managing session state,

Windows Server AppFabric Caching Session State Provider
1. In-Proc

2. SQL Server Mode

3. Custom


We can use custom session state mode to store session state in AppFabric cache.

To use AppFabric cache for session state we need to configure our application's web.config file according to steps mentioned below.

First of all make sure Windows Server AppFabric is installed and running.


Read install and configure windows server AppFabric to know how to install and configure windows server AppFabric.

Now add references to the following assemblies by right clicking on solution explorer and select add reference.

browse to AppFabric directory in windows/system32, select and add reference to both assemblies mentioned below.

Microsoft.ApplicationServer.Caching.Client.dll 
Microsoft.ApplicationServer.Caching.Core.dll

Now open web.config file and add following in configSection


  


Make sure to change your HOSTNAME in code below.


  
  
    
  



Add this code inside system.web element in web.config

Make sure you write the correct cache name, i m using default cache.


  
    
  



Now we can use AppFabric cache to store our session state as we used to do normally.

protected void Page_Load(object sender, EventArgs e)
{
    // Just and example of storing data in session variables

    Session["Test"] = "AppFabricTest";
   
}

protected void btnTest_Click(object sender, EventArgs e)
{
     lblShow.Text = Session["Test"].ToString(); 
}

1

Install Configure Windows Server AppFabric

Install Configure Windows Server AppFabric Cache Services In Asp.Net 3.5 and 4.0.

Install Windows Server Appfabric
Here i am explaining steps to install and configure windows server appfabric cache services in asp.net 3.5 and 4.0.

1. Download and run windows server appfabric from this link

Select the features you want to install, Confirm the next screen and finish the installation.


Install AppFabric

After installation is finished, Go start > all programs> windows server AppFabric and launch configure AppFabric

ConfigureAppFabric

Click on caching service tab and configure it as shown in picture.

Configure windows server appfabric

Windows server AppFabric




Once configuration is done, you need to start the cache services.

For this open Caching Administration Windows PowerShell from the Appfabric menu and type and run below mentiond command.

C:\> Start-CacheCluster

HostName : CachePort Service Name Service Status Version Info
-------------------- ------------ -------------- ------------
AMIT:22233 AppFabricCachingService UP 1 [1,1][1,1]


Now cache services are up and running.

You can change the startup type of cache services to automatic from MMC snap add in.



Hope this helps


Find More Articles