Visual Studio Web Server External Access

December 13, 2012 at 9:35 PMAmer Gerzic

Visual Studio has always been my favorite development tool. From debugging to deployment, Visual Studio provides a developer with various options to produce excellent software. However, just like any other tool, there are some limitations. One of those limitations is Visual Studio Web Server (Cassini), which is included with Visual Studio installation.

Visual Studio Web Server has limitation (for obvious reasons) to serve web pages that are accessed via localhost exclusivly. In the past, that has not been a problem because development and debugging was performed on local machine. However, since the iPhone revolution, developing iPhone/Android applications that require connectivity to a web server requires connectivity from devices, which cannot access VS Web Server. Using single machine for development was not possible.

In order to solve such issue, I had to make sure that all my web requests are initiated from localhost. To achieve that, I decided to write a server that would forward all web traffic to Visual Studio Web Server; sort of a “man-in-the-middle-attack”. Except that in this case, there is no “attack” but rather simple network traffic forwarding in both directions. Following port/address forwarding application was born:

TcpPortForwardScreen

Parameters are self explanatory:

  1. Listen to – port/IP that server is listening to;
  2. Forward to – port/IP that server is forwarding requests (this is port/address of Cassini Web Server – the address is always “localhost”);
  3. Replace “Host” value for all HTTP Requests – IIS Express is checking HTTP header values to determine where the request is coming from, so I implemented simple “host” header replacement to mimic access from local host;

To use it, simply set parameters and click on Start button. You should be able to access you Cassini web application from anywhere within you network.

 

Source Code

Installation file includes source code. Source code is written in .NET using Visual Studio 2012, but it can be easily ported to .NET 2.0. I decide to publish source code for 2 reasons:

  1. The application is not extensively tested and there may be need for corrections. I will correct the code as I find issues, but so far it has been working well and it passed all tests. If you do make corrections, please let me know so that I can make those fixes on my end.
  2. The application is good example of .NET asynchronous socket programming and it may be modified for other purposes. If you choose to use the source for own purposes, please give credit where credit due i.e. please let me and users know about code reuse.

Download Installation (with Source Code) (1,011.41 kb)

Posted in:

Tags: ,

Comments (2) -

The download link doesnt work

Amer Gerzic
Amer Gerzic says:

Download link is fixed now ... thanks for letting me know!

Add comment

biuquote
Loading