Reputation: 153
I had written a WCF service to Host Domain on IIS ,and I had hosted that WCF service to IIS. My Code is
public bool HostWebsiteToIIS(string DomainName)
{
bool Hosted = false;
try
{
string DomainNameRecord = "";
if (DomainName.ToLower().Contains(".com"))
{
DomainNameRecord = "www." + DomainName.ToLower();
}
else{
DomainNameRecord = "www." + DomainName.ToLower()+".com";
}
using (ServerManager manager = ServerManager.OpenRemote("Host"))
{
manager.Sites["Default Web Site"].Bindings.Add("*:80:" + DomainNameRecord, "http");
manager.CommitChanges();
Hosted = true;
}
return Hosted;
}
catch
{
return Hosted;
}
}
this is method I had used in my WCF, but this is throwing Exception as
cannot read configuration file due to insufficient permissions
I had tried following steps
In Windows Explorer, locate the web.config file that is associated with the Web site. Right-click the web.config file Click Properties. Click the Security tab, and then click Edit. Click Add. In the Enter the object names to select box, type computername\IIS_IUSRS, click Check Names, and then click OK. Note Computername is a placeholder for the computer name. Click to select the Read check box, and then click OK. In the Web.config Properties dialog box, click OK.
but this is not working for me please help
Upvotes: 2
Views: 83
Reputation: 153
Click on Application Pool ->Right Click on WCF Service Hosted->Go To Advance Setting->Within process select identity ->change "Application Pool" to "Local System" it works.
Upvotes: 0
Reputation: 63143
Microsoft.Web.Administration
API you are using requires the code to run under an account that has administrator permissions on the target IIS machine.
In your case, the error message simply indicates that the executing account have no such permission. The file it refers to is the applicationHost.config of IIS, not your web.config. Changing that file's NTFS permission is useless.
Upvotes: 1