[Solved] Azure Configure Redis Session State asp.net
What is Redis
![]() |
Redis Cache |
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 ConsoleUse following command to install it
Install-Package Microsoft.Web.RedisSessionStateProviderAfter 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
<system.web> <sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <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"/> </providers> </sessionState> </system.web>
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
Reviewed by TechDoubts
on
2:35 AM
Rating:
![[Solved] Azure Configure Redis Session State asp.net](https://2.bp.blogspot.com/-FlKcnDuFrfI/WSf1PmLPbVI/AAAAAAAAAeA/LBd2PaSFemw4VizzY3UyCTLA0YzNt1iXgCLcB/s72-c/%255BTechDoubts.Net%255DRedis.png)
No comments: