Die CGI/Isapi Einschränkungen für das .net 4.0 Framework sind standardmäßig deaktiviert. Der Code aktiviert die Extensions.
/// <summary>
/// Enable the web extension to .net 4.0 framework.
/// </summary>
public void Enable40WebExtension()
{
//enable .net 4.0 processing at isapi/cgi settings in IIS 7
using (var serverManager = new ServerManager())
{
var config = serverManager.GetApplicationHostConfiguration();
var sections = config.GetSection("system.webServer/security/isapiCgiRestriction");
var items = sections.GetCollection();
var configurationElement = items.FirstOrDefault(item => item.Attributes["groupId"].Value.ToString() == "ASP.NET v4.0.30319");
if (configurationElement != null)
configurationElement.SetAttributeValue("allowed", true);
serverManager.CommitChanges();
}
}
Kommentare zum Snippet