首先開一個Web專案
[![](http://3.bp.blogspot.com/-W0eH1UB-UAg/VL9vePbpb0I/AAAAAAAACI4/dA1ZpbAc2uo/s1600/01.%E9%96%8B%E6%96%B0%E5%B0%88%E6%A1%88.png)](http://3.bp.blogspot.com/-W0eH1UB-UAg/VL9vePbpb0I/AAAAAAAACI4/dA1ZpbAc2uo/s1600/01.%E9%96%8B%E6%96%B0%E5%B0%88%E6%A1%88.png) 安裝Microsoft.Web.RedisSessionStateProvider套件 [![](http://1.bp.blogspot.com/-DuvFSvwfNg4/VL9vy-aDZCI/AAAAAAAACJA/Isrbq2EmYPE/s1600/02.%E5%AE%89%E8%A3%9D%E5%A5%97%E4%BB%B6.png)](http://1.bp.blogspot.com/-DuvFSvwfNg4/VL9vy-aDZCI/AAAAAAAACJA/Isrbq2EmYPE/s1600/02.%E5%AE%89%E8%A3%9D%E5%A5%97%E4%BB%B6.png) 設定檔中的sessionState自動會加入一段設定,註解的說明也很清楚 <?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <compilation debug="true" targetFramework="4.5" /> <httpRuntime targetFramework="4.5" /> <sessionState mode="Custom" customProvider="MySessionStateStore"> <providers> <!-- Either use 'connectionString' and provide all parameters as string OR use 'host','port','accessKey','ssl','connectionTimeoutInMilliseconds' and 'operationTimeoutInMilliseconds'. --> <!-- 'throwOnError','retryTimeoutInMilliseconds','databaseId' and 'applicationName' can be used with both options. --> <!-- <add name="MySessionStateStore" host = "127.0.0.1" [String] port = "" [number] accessKey = "" [String] ssl = "false" [true|false] throwOnError = "true" [true|false] retryTimeoutInMilliseconds = "