博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
网站安装打包 浏览网站[五] 附加IIS其它功能
阅读量:7218 次
发布时间:2019-06-29

本文共 1555 字,大约阅读时间需要 5 分钟。

hot3.png

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

代码就一句:

 

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

 

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

 


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

 

IIS重启:

 

05233808_FzsH.gif 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 开启:

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

 

IIS 停止:

 

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

 

注册asp.net:

 

05233808_FzsH.gif 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
"
);

 

 

打完,收工!

转载于:https://my.oschina.net/secyaher/blog/274376

你可能感兴趣的文章
review board
查看>>
URAL 1495 One-two, One-two 2
查看>>
牛客国庆集训派对Day3 G Stones
查看>>
虚函数简单总结
查看>>
插入排序--算法导论
查看>>
NoSQL -- Redis使用
查看>>
处理iphone的 .play() 不能播放问题
查看>>
jetty404web界面服务器信息隐藏
查看>>
22个Photoshop网页设计教程网站推荐
查看>>
如何让程序员更容易的开发Web界面?重构SmartAdmin展示TinyUI
查看>>
centos7 python2和python3共存
查看>>
rhel6.2配置在线yum源
查看>>
分级聚类算法
查看>>
Web Services 入门(之二)
查看>>
随机模拟MCMC和Gibbs Sampling
查看>>
网络安全是一种态度
查看>>
POJ1131 Octal Fractions
查看>>
mysql-ulogd2.sql
查看>>
119. Pascal's Triangle II - Easy
查看>>
349. Intersection of Two Arrays - Easy
查看>>