Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using (var server = new ServerManager())
- {
- try
- {
- Site site = server.Sites[RoleEnvironment.CurrentRoleInstance.Id + "_Web"];
- string physicalPath = site.Applications["/"].VirtualDirectories["/"].PhysicalPath;
- string webConfigPath = Path.Combine(physicalPath, "web.config");
- var doc = System.Xml.Linq.XDocument.Load(webConfigPath);
- var redisCacheProviderSettings = doc.Descendants("sessionState").Single().Descendants("providers").Single().Descendants("add").Single();
- redisCacheProviderSettings.SetAttributeValue("host", RoleEnvironment.GetConfigurationSettingValue("SessionRedisCacheHost"));
- redisCacheProviderSettings.SetAttributeValue("accessKey", RoleEnvironment.GetConfigurationSettingValue("SessionRedisCacheAccessKey"));
- redisCacheProviderSettings.SetAttributeValue("ssl", "true");
- redisCacheProviderSettings.SetAttributeValue("throwOnError", "false");
- doc.Save(webConfigPath);
- }
- catch (Exception ex)
- {
- // Log error
- }
- }
Add Comment
Please, Sign In to add comment