[Solved] Azure Configure Redis Session State asp.net

What is Redis

Guide to connect your asp.net web application to azure redis cache mechanism
Redis Cache

Redis is an open source NoSQL key-value data store. Which means, in Redis values are stored as like in the view state, session state in asp.net. Mainly we are using Redis for in-memory cache and session management. To learn more about Redis just go below link

Learn more about Redis from here.
Here I'm going to explain how to connect Azure Redis service  in your web application developed in asp.net.

How to create azure redis storage

Microsoft azure cloud platform provides Redis open source caching storage mechanism. You need to register in Microsoft Azure platform to do so. To know more about Microsoft Azure Redis Cache navigate to here.

Look out here for tutorial about how to add Azure Redis cache and get the access key.
We are using access key (here in this example I user primary access key, there are two access keys one is primary and secondary). So note that primary key.

How to configure Azure Redis Cache in Web asp.net Application

First of all you need to install Microsoft.Web.RedisSessionStateProvider dynamic link library (DLL) in your asp.net web application. Which will be available from NuGet. Open your package manager console from visual studio

Tools -> NuGet Package Manager -> Package Manager Console
Use following command to install it

Install-Package Microsoft.Web.RedisSessionStateProvider 
After successfully installed the Redis provider, you can see that in the References section of your web application (Bin if it is a website).

Now open your Web.config file, you will see some new code lines under the system.web section to configure your Redis session state details like below code

    <sessionState mode="Custom" customProvider="MySessionStateStore">
        <add name="MySessionStateStore" type="Microsoft.Web.Redis.RedisSessionStateProvider" host="<your host name>:6380" accessKey="<your primary access key>" ssl="true"  connectionTimeoutInMilliseconds = "5000" operationTimeoutInMilliseconds = "1000" retryTimeoutInMilliseconds="3000"/>

Provide your host name and primary access key in the appropriate attributes as shown above. You are done.
[Solved] Azure Configure Redis Session State asp.net [Solved] Azure Configure Redis Session State asp.net Reviewed by TechDoubts on 2:35 AM Rating: 5

No comments:

Powered by Blogger.