在创建完网站与虚拟目录,接下来就是要浏览网站了,于是,在界面上多加一个按钮,点击浏览是顺势而加了:

代码就一句:

 

Process.Start("iexplore.exe"string.Format("http://{0}",txtWebsiteIP.Text));

 

 //IP地址用System.Net.Dns.GetHostAddresses(Dns.GetHostName())[0].ToString()就可获取

 


以下附加一下IIS一些其它功能:

 

IIS重启:

 

IIS重启
  public static bool ReStart(out string msg)
        {
            
try
            {
                msg 
= "";
                ServiceController iis 
= new ServiceController("iisadmin");
                
if (iis.Status == ServiceControllerStatus.Running)
                {
                    iis.Stop();
                }
                Process.Start(
"iisreset");//重启
                iis.Dispose();
                
return true;
            }
            
catch (Exception err)
            {
                msg 
= err.Message;
            }
            
return false;
        }

 

 IIS 开启:

IIS Start
 public static bool Start()
        {
            ServiceController iis 
= new ServiceController("iisadmin");
            
if (iis.Status == ServiceControllerStatus.Stopped)
            {
                iis.Start();
            }
            iis.Dispose();
            
return true;
        }

 

IIS 停止:

 

IIS Stop
public static bool Stop()
        {
            ServiceController iis 
= new ServiceController("iisadmin");
            
if (iis.Status == ServiceControllerStatus.Running)
            {
                iis.Stop();
            }
            iis.Dispose();
            
return true;
        }

 

注册asp.net:

 

aspnet 注册
 string aspnet_regiisPath=@"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\aspnet_regiis.exe";
            
if (!System.IO.File.Exists(aspnet_regiisPath))
            {
                aspnet_regiisPath 
= aspnet_regiisPath.Replace("C:""D:");
                
if (!System.IO.File.Exists(aspnet_regiisPath))
                {
                    aspnet_regiisPath 
= aspnet_regiisPath.Replace("D:""E:");
                    
if (!System.IO.File.Exists(aspnet_regiisPath))
                    {
                        MessageBox.Show(
"找不到Aspnet_regiis.exe的文件路径!");
                        
return;
                    }
                }
            }
            Process.Start(aspnet_regiisPath, 
"-i");

 

 

打完,收工!

posted on 2010-01-27 11:34  路过秋天  阅读(1400)  评论(4编辑  收藏  举报
路过秋天