C # create site in IIS programmatically in asp.net project
I am trying to create a site in IIS using Microsoft.Web.Administration dll in C #. I am using the following code
using (var serverManager = new ServerManager())
{
ApplicationPool pool = serverManager.ApplicationPools.Add(ClientDomain);
pool.ManagedRuntimeVersion = "v4.0";
Site site = serverManager.Sites.Add(SiteName, httpProtocol, httpBindingInformation, physicalPath);
site.Bindings.Add(httpsBindingInformation, httpsProtocol);
serverManager.CommitChanges();
}
I am getting the following exception: "Method or operation not implemented" when I run the code from an asp.net project, but if the same code is run from a console project, it works fine. Following is the details of the exception
at Microsoft.Web.Administration.Interop.IAppHostProperty.get_Value()
at Microsoft.Web.Administration.ConfigurationElement.GetPropertyValue(IAppHostProperty property)
at Microsoft.Web.Administration.ConfigurationElement.GetAttributeValue(String attributeName)
at Microsoft.Web.Administration.Binding.get_CertificateHash()
at Microsoft.Web.Administration.BindingCollection.Add(Binding binding)
at Microsoft.Web.Administration.BindingCollection.Add(String bindingInformation, String bindingProtocol)
at TestProject.BLL.CRMSiteManagement.CRMSiteIISSetup.Process() in e:\CRMSiteManagement\CRMSiteIISSetup.cs:line 35
at TestProject.BLL.CRMSiteManagement.CRMSiteService.CreateNewCRMSite(CRMSite newSite) in e:CRMSiteManagement\CRMSiteService.cs:line
It seems to be a rights issue, but I don't know how to fix it. Update 1: The error goes along the following line of code on localhost
site.Bindings.Add(httpsBindingInformation, httpsProtocol);
+3
source to share
1 answer