This project is read-only.
2
Vote

Tweak to support multiple instances of Cassinidev in the same application

description

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.
 
Thoughts?
-Aakash

comments

Sky wrote Jun 11, 2012 at 8:27 AM

Great catch. At first glance it appears that this modification should have no ill effects. It is being tested now.

Thank you for you contribution

wrote Jun 11, 2012 at 8:39 AM

wrote Jun 11, 2012 at 8:40 AM

wrote Feb 22, 2013 at 12:19 AM

wrote Jun 24, 2013 at 10:04 PM