This is my current setup;
In IIS I have two hosted MVC applications, say App1
is hosted in app1.mydomain.com
. It has a virtual MVC application (not directory) App2
hosted as app1.mydomain.com/app2
.
Both applications have a connection to the same WCF service. This WCF service requires headers in their requests and thus I have added behaviours for every call using this.
I have configured both applications' header behaviour correctly (App1
has App1MessageHeaderInspector
and App2
has App2MessageHeaderInspector
) and have configured both in their own Web.config.
So, App1
uses;
<client>
<endpoint address="http://ws.mydomain.com/Service.svc" binding="basicHttpBinding"
bindingConfiguration="BasicHttpBinding_IWebService" contract="WCFService.IWebService"
name="BasicHttpBinding_IWebService" behaviorConfiguration="WebServiceEndpointBehaviour" />
</client>
<extensions>
<behaviorExtensions>
<add name="App1MessageHeaderInspector" type="App1.App1MessageHeaderBehaviourExtension, App1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null "/>
</behaviorExtensions>
</extensions>
<behaviors>
<endpointBehaviors>
<behavior name="WebServiceEndpointBehaviour">
<App1MessageHeaderInspector />
</behavior>
</endpointBehaviors>
</behaviors>
And App2
uses the same configuration, except that App1MessageheaderInspector
is App2MessageHeaderInspector
.
I have configured my routing in App1
to ignore everything going to /app2
;
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.IgnoreRoute("{*path}", new { path = @"app2\/(.*)" });
//...
}
And I can succesfully view pages which do not require a connection to the WCF service (i.e. app1.mydomain.com/app2/Home/Index
returns the correct view).
Now my problem is, as soon as I try to connect to the WCF service with App2
, I get the following error;
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: The type 'App1.App1MessageHeaderBehaviourExtension, App1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null ' registered for extension 'App1MessageHeaderInspector' could not be loaded.
But I don't want App2
to load the behaviours from App1
!
I have also tried to encapsulate <system.web>
with <location inheritInChildApplications="false">
in App1
, but without success.
Both applications work as intended when testing from my local PC. There is no Windows authentication or anything like that involved.
I am quite stuck on this topic for a few days now. Any help is appreciated.