I am testing an application that is listening on multiple ports (80, 81 etc). When I loaded more than 1 instances of CassinidevServer into my test application, I found that URL's would inexplicably get changed - ie I sent a request like
http://localhost:81/Foo but it would be received as http://localhost:80/Foo in ASP.Net
MVC hosted inside Cassini.
After some digging I found that the problem is related to how Cassini handles appdomains in Server.cs: CreateWorkerAppDomainWithHost. Since the listening port number is not used part of the uniqueAppString that is generated here, two different CassiniDevServer
instances listening on different ports but within the same application container will end up with one of them getting the other's Host container in GetHost(). Furthermore the port for the incoming URL is pulled out of the host object's listening port information,
as opposed to the localport information in the Connection object.
The fix I made locally for this is quite simple - I added the listening port as a parameter to CreateWorkerAppDomainWithHost, and made it part of the uniqueAppString. This forces each CassiniDevServer instance in my app to get its own appdomain, and things
seem to work smoothly thence.