AddApplication() public static method

public static AddApplication ( string siteName, string applicationPath, string applicationPool, string physicalPath, string userName, string password ) : bool
siteName string
applicationPath string
applicationPool string
physicalPath string
userName string
password string
return bool
示例#1
0
        /// <summary>
        /// Install the IIS samples.
        /// </summary>
        /// <param name="stateSaver"></param>
        /// <remarks>
        /// 1. check for Default Web Site
        /// 2. create AppPool named "PhalangerAppPool" (if not yet)
        /// 3. create application "Default Web Site"/"Phalanger..." using AppPool "PhalangerAppPool"
        /// </remarks>
        public override void Install(IDictionary stateSaver)
        {
            try
            {
                IIS.CreateApplicationPool(
                    PhalangerAppPool,
                    Microsoft.Web.Administration.ProcessModelIdentityType.ApplicationPoolIdentity, null, null,  // IIS defaults
                    ManagedRuntimeVersion, true,
                    true, // enable 32bit 
                    Microsoft.Web.Administration.ManagedPipelineMode.Integrated,
                    1000, new TimeSpan(0, 20, 0), 0, new TimeSpan(0, 0, 0)  // IIS defaults
                    );
            }
            catch (System.Runtime.InteropServices.COMException)
            {
                ShowError("IIS 7 is not installed properly. The installation cannot continue.");
                throw;
            }
            catch (Exception ex)
            {
                ShowError("Unable to create '{0}' IIS application pool\n\n{1}\n{2}", PhalangerAppPool, ex.Message, ex.GetType());
            }

            foreach (var sample in Samples)
            {
                try
                {
                    IIS.AddApplication(DefaultWebSite, ApplicationDir(sample), PhalangerAppPool, WebSamplesDir + '\\' + sample, null, null);
                }
                catch (System.Runtime.InteropServices.COMException)
                {
                    ShowError("IIS 7 is not installed properly. The installation cannot continue.");
                    throw;
                }
                catch (Exception ex)
                {
                    ShowError("Unable to create '{0}' IIS application in '{1}'\n\n{2}", sample, DefaultWebSite, ex.Message);
                }
            }
        }