通过Process.Start启动,VS自带程序WebDev.WebServer40.EXE

在内网架设网站时,为安装IIS条件下用VS自带的小程序来测试效果非常不错!

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Net;
using System.Net.NetworkInformation;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms; namespace WebServer
{
public partial class FormApp : Form
{
public FormApp()
{
InitializeComponent();
} private void btnStart_Click(object sender, EventArgs e)
{
string _AppRoot = this.txtAppRoot.Text;
string _Port = this.txtPort.Text;
string _WebPath = this.txtWebPath.Text;
string _WebvPath = this.txtWebvPath.Text;
try
{
//简单校验
CheckBoolTxt(_AppRoot, _Port, _WebPath, _WebvPath);
string arguments = string.Format("/port:{0} /path:{1} /vpath:{2}", _Port, _WebPath, _WebvPath);
System.Diagnostics.Process.Start(_AppRoot, arguments);
this.linkLabel1.Text = string.Format("http://localhost:{0}{1}", _Port, _WebvPath);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "提示:");
}
} private void CheckBoolTxt(string _AppRoot, string _Port, string _WebPath, string _WebvPath)
{
if (!System.IO.File.Exists(_AppRoot))
{
throw new Exception("找不到指定程序!");
}
if (!System.Text.RegularExpressions.Regex.IsMatch(_Port, @"^(([1-6][0-5][0-5][0-3][0-5])|([1-9][0-9][0-9][0-9])|([1-9][0-9][0-9])|([1-9][0-9])|([1-9]))$")) //^[1-6]?[\d]{0,4}$
{
throw new Exception("端口:1-65535之间未使用的端口号!");
}
if (!System.IO.Directory.Exists(_WebPath))
{
throw new Exception("物理路径不存在,请指定有效的目录!");
}
if (!_WebvPath.Contains("/"))
{
throw new Exception("虚拟目录必须以'/'开头!");
}
IPGlobalProperties ipProperties = IPGlobalProperties.GetIPGlobalProperties();
IPEndPoint[] ipEndPoints = ipProperties.GetActiveTcpListeners();
int counts = ipEndPoints.Count<IPEndPoint>(o => o.Port == int.Parse(_Port));
if (counts > )
{
throw new Exception("端口已被占用!");
}
} private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
{
System.Diagnostics.Process.Start(this.linkLabel1.Text);
}
}
}

C# 调用VS自带程序WebDev.WebServer40.EXE 源代码的更多相关文章

  1. vs2010旗舰版后,运行调试一个项目时调试不了,提示的是:无法使用“pc”附加到应用程序“webdev.webserver40.exe(PID:2260”

    具体问题描述: vs2010旗舰版后,运行调试一个项目时调试不了,能编译,按ctrl+f5 可以运行,但是就是调试就不行,提示的是:无法使用“pc”附加到应用程序“webdev.webserver40 ...

  2. 开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误

    已经解决,问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open() ...

  3. ASP.NET程序运行出现WebDev.WebServer40.exe已停止工作解决方法(netsh winsock reset)

    问题描述:在开发系统时候运行程序突然报出"WebDev.WebServer40.exe已停止工作"的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.O ...

  4. 在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误的解决办法

    问题描述:在开发系统时候运行程序突然报出“WebDev.WebServer40.exe已停止工作”的错误,程序调试运行,发现程序在打开数据库时候报错,也就是Connection.Open()处. 但是 ...

  5. WebDev.WebServer40.EXE

    http://www.cnblogs.com/tong-tong/archive/2013/05/02/3049428.html 大学玩asp.net时就发现VS在Debug时会起一个web服务,这东 ...

  6. WebDev.WebServer40.EXE命令使用

    "C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\WebDev.WebServer40.EXE&quo ...

  7. 用WebDev.WebServer40.EXE调试VS代码

    1.找到WebDev.WebServer40的录井,一般位于C:/Program Files (x86)/Common Files/Microsoft Shared/DevServer/10.0/We ...

  8. WebDev.WebServer40.exe已停止工作

    今天写程序的遇到这个错误 错误的原因是代码中有死循环

  9. VS WebDev.WebServer40

    vs2010下有一个WebDev.WebServer40工具,可以直接拿来当服务器用,这样就不用再安装iis了.位置在 C:\Program Files (x86)\Common Files\micr ...

随机推荐

  1. Windows下免费软件的首选推荐

    PS:以下按装机顺序排列,“|”号后面是备选软件. 启动引导:EasyBCD 虚拟机:VirtualBox Linux:Zorin | Linux Mint(Mate) | Ubuntu 驱动工具:驱 ...

  2. Linux 部署jenkins + svn + mavne + tomcat8自动化部署

    1,下载Jenkins  war包   官网下载地址 https://jenkins.io/ 2.初始化安装 1)首次启动jenkins,出于安全考虑,jenkins会生成一个随机的口令到 /root ...

  3. 超级拷贝scp

    scp -r 超级拷贝,其是ssh的一个组件,通过ssh访问来拷贝文件.首先保证已安装openssh-server. 用法:scp -r 目标用户名@目标ip:目标文件绝对路径  存放位置 $ scp ...

  4. 密码学hash函数-SHA256-512

    [latexpage] Hash函数又称哈希函数.散列函数.杂凑函数.它是一种单向密码体制,即从一个从明文到密文的不可逆映射,只有加密过程,没有解密过程. Hash函数H将可变长度的数据块M作为输入, ...

  5. 一个基于 EasyUI 的前台架构(3)封装操作Tabs的JS代码

    一般来说,系统框架的主内容区会引入另一个独立的 Web 页面来实现系统的功能,所以在在 Tabs 里的每一个标签页里使用 iframe 标签来引入子页面.所以这里可以将 Tabs 的 Content ...

  6. Linux Linux常用命令二

    whoami 我是谁命令 --该命令用户查看当前系统当前账号的用户名 --由于系统管理员通常需要使用多种身份登录系统,李儒通常使用普通用户登录系统,然后再以su命令切换到root身份对系统进行灌篮.这 ...

  7. Eclipse 创建 Java 类

    打开新建 Java 类向导 你可以使用新建 Java 类向导来创建 Java 类,可以通过以下途径打开 Java 类向导: 点击 "File" 菜单并选择 New > Cla ...

  8. Ubuntu下MongoDB的安装和使用

    本博文介绍了MongoDB,并详细指引读者在Ubuntu下MongoDB的安装和使用.本教程在Ubuntu14.04下测试通过.(2017.09.07) 安装MongoDB MongoDB安装很简单, ...

  9. CodeForces 450A 队列

    Description There are n children in Jzzhu's school. Jzzhu is going to give some candies to them. Let ...

  10. Android Studio3.0 配置ButterKnife出错的解决

    需要注意的问题: (1)ButterKnife.bind(this);必须在设置布局之后进行初始化: 官方升级到了8.8.1了 compile 'com.jakewharton:butterknife ...