Cassini only works on Loopback

Friday, 17 April 2009 07:41 AM
by Coose

I needed a simple ASP.NET web server scenario that I could debug and turn on and off when required.  Reconfiguring IIS is a real pain to do that with, so I tried debugging my scenario with Cassini (also called ASP.NET Development Server, and Visual Studio Web Developer Server, etc).

All was fine until I tried accessing that web site from a remote machine.  Surely they didn’t write Cassini so that it listens on loopback only?  Could they?

They did.

Fortunately, they also publish the code for Cassini.  The latest 3.5 version from October 3, 2008 can be found here.  It includes some nice upgrades from v1 and 2, namely a Visual Studio project!  Also runs as a standalone exe, no need to put Cassini.dll in the GAC.  Also they fixed the horrible colors of the textboxes:

 image

 

To make it accessible from a remote machine is pretty simple. In the file Server.cs, change the calls to “CreateSocketBindAndListen” to listen on IPAddress.Any instead of IPAddress.Loopback.  Now you have a web server that can be accessed from remote machines.

   86 public void Start() {

   87     try {

   88         _socket = CreateSocketBindAndListen(AddressFamily.InterNetwork, IPAddress.Any, _port);

   89     }

   90     catch {

   91         _socket = CreateSocketBindAndListen(AddressFamily.InterNetworkV6, IPAddress.IPv6Any, _port);

   92     }

Update:

One thing to note about using Cassini is that it doesn’t support NTLM, so Windows authentication will not work.  I will post a fix/workaround for that next time.

Comment on this
Development

Add comment

  Country flag

biuquote
  • Comment
  • Preview
Loading