When you use DirectoryEntry to manipulate IIS, you can set many properties. But when you use some of the classes in Microsoft.Web.Administration, you don't know where to set. For example: Accessscript,accessread, directory browsing, anonymous access, and other properties. I am now writing the following code:
using (servermanager SM = new Servermanager ())
{
ApplicationPool newpool = Sm. applicationpools["Newpool"];
if (Newpool = = null)
{
Newpool = Sm. Applicationpools.add ("Newpool");
Newpool.autostart = true;
Newpool.managedruntimeversion = "v4.0";
Newpool.enable32bitapponwin64 = true;
Sm.commitchanges ();
}
Site defaultsite = Sm. sites["Default Web Site"];
Application newapplication = defaultsite.applications["Newapplication"];
if (newapplication!=null)
{
DefaultSite.Applications.Remove (newapplication);
}
Newapplication = DefaultSite.Applications.Add ("/newapplication",
@ "F:\Silverlight\PrismModule\PrismModule.Web");
Newapplication.applicationpoolname = "Newpool";
Sm.commitchanges ();
}
This will also correctly create an application under the default Web site, and I would like to know how to set the properties mentioned above.
Problem solving. IIS7 The configuration information about the site is stored through the config file, which is set primarily in Applicaitonhost.config and Web. config. Use the configuration class in the Microsoft.Web.Administration
IIS7 Microsoft.Web.Administration Creating application issues