在创建完网站与虚拟目录,接下来就是要浏览网站了,于是,在界面上多加一个按钮,点击浏览是顺势而加了:
代码就一句:
Process.Start( " iexplore.exe " , string .Format( " http://{0} " ,txtWebsiteIP.Text));
//IP地址用System.Net.Dns.GetHostAddresses(Dns.GetHostName())[0].ToString()就可获取
以下附加一下IIS一些其它功能:
IIS重启:
![](http://static.oschina.net/uploads/img/201406/05233808_g0KL.gif)
![05233808_FzsH.gif](http://static.oschina.net/uploads/img/201406/05233808_FzsH.gif)
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 开启:
![](http://static.oschina.net/uploads/img/201406/05233808_g0KL.gif)
![05233808_FzsH.gif](http://static.oschina.net/uploads/img/201406/05233808_FzsH.gif)
public static bool Start() { ServiceController iis = new ServiceController( " iisadmin " ); if (iis.Status == ServiceControllerStatus.Stopped) { iis.Start(); } iis.Dispose(); return true ; }
IIS 停止:
![](http://static.oschina.net/uploads/img/201406/05233808_g0KL.gif)
![05233808_FzsH.gif](http://static.oschina.net/uploads/img/201406/05233808_FzsH.gif)
public static bool Stop() { ServiceController iis = new ServiceController( " iisadmin " ); if (iis.Status == ServiceControllerStatus.Running) { iis.Stop(); } iis.Dispose(); return true ; }
注册asp.net:
![](http://static.oschina.net/uploads/img/201406/05233808_g0KL.gif)
![05233808_FzsH.gif](http://static.oschina.net/uploads/img/201406/05233808_FzsH.gif)
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 " );
打完,收工!