明永成

导航

 

http://www.cnblogs.com/huigll/archive/2011/02/25/1851112.html

 

Vs自带的Visual Studio Development_server非常好用.比XP的IIS强多了. XP的IIS经常报访问数过多.

但是, WebDev.WebServer.exe 有个限制就是,只能内环网访问,就是只能用localhost 或者127.0.0.1访问.

要是能够对外服务的话,岂不是可以当个IIS 了?

 

查了一下引用.只用了WebDev.WebHost.dll. 理论上有了WebDev.WebHost.dll和WebDev.WebServer.exe就可以架设了.

现在需要的就是去掉内环访问限制.从Reflector中查找:

在 方法里:

 
Microsoft.VisualStudio.WebHost.Server
复制代码
publicvoid Start() {     this._socket =new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);     this._socket.ExclusiveAddressUse =true;     try     {        this._socket.Bind(new IPEndPoint(IPAddress.Loopback, this._port));//这里开启的是内环网监听.     } .......
复制代码

 

改成:

this._socket.Bind(new IPEndPoint(IPAddress.Any, this._port));

 

Declaring Type:Microsoft.VisualStudio.WebHost.Request

privatebool TryParseRequest()

复制代码
{     this.Reset();     this.ReadAllHeaders();    if (!this._connection.IsLocal)//这里检查了是不是本地的请求.需要弊掉.     {         this._connection.WriteErrorAndClose(0x193);         returnfalse;     }    ....略     returntrue; }
复制代码

基本就去掉内环网访问的限制了.

下面就需要来修改.

1. 首先把WebDev.WebHost.dll去掉强命名,再反编译成IL.

2. 修改IL.

3.编译IL.编译要用新的Key给它强命名.

4.把 WebDev.WebServer.exe 反编译成IL,把引用WebDev.WebHost.dll的签名改成刚生成的.

5.编译新的WebDev.WebServer.exe.

 

 

WebDevServer.rar

https://files.cnblogs.com/huigll/WebDev.WebServer40.rar

posted on 2013-09-15 13:32  明永成  阅读(262)  评论(0编辑  收藏  举报