How to define connection string for session state in Azure

后端 未结 4 1400
傲寒
傲寒 2020-12-19 05:37

I am using the RedisSessionStateProvider using a procedimient like this https://azure.microsoft.com/en-us/documentation/articles/web-sites-dotnet-session-state-

4条回答
  •  忘掉有多难
    2020-12-19 06:12

    I think IPartitionResolver can come to rescue here...

    You can basically create a class that implements System.Web.IPartitionResolver interface and specify it in the sessin state configuration in web.config as this

    
    

    And then in the class you can override the connection string

    public class WebAppConnectionStringResolver : System.Web.IPartitionResolver
    {
       public void Initialize()
       {
    
       }
    
       public string ResolvePartition(object key)
       {
         return System.Configuration.ConfigurationManager.ConnectionStrings["your_Conn_string_name_in_portal"]
       }
    }
    

    I havent tested this out but I believe this should work

    Read more at

    • https://msdn.microsoft.com/en-us/library/system.web.configuration.sessionstatesection.partitionresolvertype(v=vs.110).aspx
    • https://msdn.microsoft.com/en-us/library/system.web.ipartitionresolver(v=vs.110).aspx

提交回复
热议问题