随笔 - 714  文章 - 0  评论 - 12812  阅读 - 301万 

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

代码就一句:

 

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   路过秋天  阅读(1407)  评论(4编辑  收藏  举报
编辑推荐:
· 一个奇形怪状的面试题:Bean中的CHM要不要加volatile?
· [.NET]调用本地 Deepseek 模型
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· .NET Core 托管堆内存泄露/CPU异常的常见思路
· PostgreSQL 和 SQL Server 在统计信息维护中的关键差异
阅读排行:
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· DeepSeek “源神”启动!「GitHub 热点速览」
· 我与微信审核的“相爱相杀”看个人小程序副业
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
· 上周热点回顾(2.17-2.23)
路过秋天
点击右上角即可分享
微信分享提示