user256890
user256890

Reputation: 3424

Breaking AppDomain boundary of ASP.NET website

I am building an integrated testing environment dedicated to a particular bunch of applications. The testing environment relies on VS testing infrastructure. The test subject apps are a web clients, therefore the test environment needs to became the web server. To cater for this need, I fire up Cassini in the test environment that loads the web site during the test. All fine and works. So the process is as follows:

  1. Test environment fires up Cassini, loads my web site
  2. Test enviroment triggers the test subject app that calls my website
  3. The test environment should compare the actual website content changes with the expected changes.

The problem occurs in step 3. My test environment and Cassini runs in one AppDomain, the website runs in another one. How can I break through the appdomain boundaries?

I have full controll over the

My first idea was to make Cassini load the website into its own AppDomain, but I failed to make that happen. Do you have any proposals?

Upvotes: 0

Views: 234

Answers (1)

user256890
user256890

Reputation: 3424

The solution appeared via digging into Cassini source code (Cassini does not consist of too much code and it is quite easy to read). After processing basic HTTP calls, Cassini passes the processing over to the ASP.NET engine by calling System.Web.HttpRuntime.ProcessRequest(simpleWorkerRequest), which invokes the ASP.NET site. The trick is that HttpRuntime class provides access to the Cache class, too! With a slight modifications of Cassini source code, the server cache can be exposed to the test environment. The only thing that needs attention is that the content of the server cache will cross the AppDomain boundary by .NET Remoting. Therefore, we have to pay attention to the cached objects making them either Serializable or MarshalByRef.

Upvotes: 1

Related Questions