Reputation: 13
I'm trying to setup a ASP.NET MVC application in a subdirectory of an Umbraco site. This new ASP.NET MVC application will run as a virtual application. For example, the Umbraco site is located at www.domain.com, and the other MVC application is located at www.domain.com/app.
I'v tried thise approach: Umbraco Child MVC Application (Virtual Directory) - Could not load file or assembly Umbraco.ModelsBuilder
It works but there are some issues.
There is not any error message, just 'The page cannot be displayed because an internal server error has occurred' when I try to go to the '/umbraco' route.
Can you, please, tell me what is wrong or how to create application in a subdirectory of Umbraco as a virtual application?
The Umbraco version is 7.7.1.
And one note - the Umbraco is hosted on the Azure.
Thanks!
Upvotes: 1
Views: 1072
Reputation: 7686
The problem is that web.config settings are inherited. Therefore, if your Umbraco installation is in the directory /wwwroot and your virtual application is in /wwwroot/app, the web.config settings for your Umbraco installation will be inherited. And it can cause major problems.
You'll see some recommendations to wrap your Umbraco's <system.web>
and <system.webServer>
sections in a <location>
tag. The problem, as you've mentioned, is that doing so prevents inheritance from some Umbraco subfolders, which breaks things such as /media and the /umbraco CMS portal.
Therefore, you'll need to override problematic web.config settings in your /app's web.config file. Here's what worked for me:
<appSettings>
tags, add <remove key="owin:appStartup" />
. <system.web><membership><providers>
section, be sure to add <clear />
as your first child. Doing so removes the inherited Umbraco.Web.Security.Providers.MembersMembershipProvider. Because if ASP.NET can't find that class, it'll present you with an exception. <system.web><roleManager><providers>
section, add a <clear />
as your first element for the same reason. <system.web><compilation><assemblies>
, add a <remove assembly="Umbraco.ModelsBuilder"/>
. Otherwise, your app will barf when it cannot locate that assembly. <remove name="UmbracoModule" /><remove name="ClientDependencyModule" /><remove name="ImageProcessorModule" />
That should do it. But the gist is to find Umbraco assemblies that are loaded in your Umbraco's web.config file that are Umbraco-specific, then remove them in your virtual application's web.config to prevent inheritance and the resulting "assembly not found" errors.
Upvotes: 0