I'm trying to setup a website from a c# application and have managed to do everything except access the "ASP" settings. I would like to be able to turn "Enable Parent Paths" on for my site.
I have so far managed everything using Microsoft.Web.Administration, any help would be really appreciated?
The code i have so far is:
var site = sManager.Sites.Add(webSite.SiteName, webSite.PhysicalLocation, webSite.Port);
site.ApplicationDefaults.ApplicationPoolName = webSite.ApplicationPoolName;
site.Bindings.Clear();
site.Bindings.Add(string.Format("{0}:{1}:{2}", webSite.BindingIP, webSite.Port, webSite.HostHeader), "http");
site.ServerAutoStart = true;
sManager.CommitChanges();
Thanks in advance.
You should read this AspSection topic in MSDN and also some basic how to on web adminstrator. Although the "how to" doesn't actually demonstrate it you should be able to cast a section to the AspSection class:
Configuration config = sManager.GetApplicationHostConfiguration();
AspSection section = (AspSection)config.GetSection("system.webServer/asp",webSite.SiteName);
section.EnableParentPaths = true;
if some reason the cast is not allowed you can use the basic attribute approach:
Configuration config = sManager.GetApplicationHostConfiguration();
ConfigurationSection section = config.GetSection("system.webServer/asp",webSite.SiteName);
ConfigurationAttribute enableParentPaths = section.GetAttribute("enableParentPaths");
enableParentPaths.Value = true;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With