Reputation: 1506
I have a WCF service app hosted in IIS 7.5. An MVC app is bound to the root URL (e.g., www.myapp.com), while the services are located at "www.myapp.com/Services". The Service library and MVC app reference .Net 4.0. Also, the service app and the mvc app are stored in two separate directories (i.e., the service app is not in a subdirectory of the MVC app).
The MVC app loads fine. However, when I load the Services URL, or browse the Service app directory in IIS, I get the following error:
Compiler Error Message: CS0234: The type or namespace name 'Mvc' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
Source Error:
Line 25: <namespaces>
Line 26: <add namespace="System.Web.Helpers" />
Line 27: <add namespace="System.Web.Mvc" />
Line 28: <add namespace="System.Web.Mvc.Ajax" />
Line 29: <add namespace="System.Web.Mvc.Html" />
Source File: e:\myapp\Web.config Line: 27
The Service assembly/project is not referencing System.Web.Mvc.
It looks like the MVC app web.config (rather than the service web.config) is being evaluated against the Service app binaries. I've searched near and far for a remedy for this, any help is much appreciated.
Finally, this error does not occur on my local IIS instance.
Upvotes: 0
Views: 1047
Reputation: 15159
This is because ASP.NET merges web.config files down the hierarchy. Just disable inheritance of system.web
section by wrapping it in MVC's web.config as follows:
<location path="." inheritInChildApplications="false">
<system.web>
........
</system.web>
</location>
Upvotes: 1
Reputation: 942
you need to create an application for the virtual directory containing the service.
This is pretty simple, go to the IIS management interface and right click the "/Services" virtual directory and select "create application"
Upvotes: 0
Reputation: 1255
You can try to clear the inherited parent configuration setting by adding something like this to your WCF service config file.
<system.web>
<pages>
<namespaces>
<clear/>
</namespaces>
</pages>
</system.web>
Upvotes: 0