I have a problem with IIS server,
How can I modify ISAPI elements with using C# language?
Forexample : ASP.net V4.0 restriction is "Not Allowed". And I want to set as "Allowed" like below picture.
I can add an elements with this Code. But I cant modify.
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample
{
private static void Main()
{
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection isapiFiltersSection = config.GetSection("system.webServer/isapiFilters");
ConfigurationElementCollection isapiFiltersCollection = isapiFiltersSection.GetCollection();
ConfigurationElement filterElement = isapiFiltersCollection.CreateElement("filter");
filterElement["name"] = @"SalesQueryIsapi";
filterElement["path"] = @"c:\Inetpub\www.contoso.com\filters\SalesQueryIsapi.dll";
filterElement["enabled"] = true;
filterElement["enableCache"] = true;
isapiFiltersCollection.Add(filterElement);
serverManager.CommitChanges();
}
}
}
Thanks For your advice.
If you want to add a restriction, you can do it with this code:
I found a solution. I changed the code like below. and it worked.