问题
I'm trying to deploy a custom, pure ASP.NET MVC app as a Virtual Directory "Application" under my Umbraco 7 site root. However, I always get the following YSOD error:
Server Error in '/DemoApp' Application.
Could not load file or assembly 'Umbraco.ModelsBuilder' or one of its dependencies. The system cannot find the file specified.
I've also tried this from scratch to eliminate as many variables as possible. Here are the repro steps:
- Created a brand new empty ASP.NET solution/project
- Added the UmbracoCms nuget package (7.4.3)
- Built the solution
- Setup my IIS Site - "UmbracoDemo" with host name
umbraco-demo.local
- Browsed to
http://umbraco-demo.local
and ran the Umbraco installer
NOTE: So far everything works as expected. I can log into the back office or browse the new Umbraco site..
- Created a new ASP.NET MVC application in a new VS solution called "DemoApp"
- Built the new solution and ran it immediately with IIS Express -- the MVC app works correctly
- In IIS Manager, I right-clicked my UmbracoDemo site and added an "Application" called "DemoApp", pointing it to the DemoApp MVC project directory
- Added "~/DemoApp" to the
umbracoReservedPaths
setting in Umbraco's web.config - Browsed to
http://umbraco-demo.local/DemoApp
Again I get the error:
Could not load file or assembly 'Umbraco.ModelsBuilder' or one of its dependencies. The system cannot find the file specified.
Additional info:
I don't think this is specifically related to ModelsBuilder. Just to see what would happen, I added this to my "DemoApp" web.config:
<assemblies>
<remove assembly="Umbraco.ModelsBuilder" />
</assemblies>
Now the error message says:
Could not load file or assembly 'UrlRewritingNet.UrlRewriter' or one of its dependencies. The system cannot find the file specified.
So naturally, I tried adding:
<remove assembly="UrlRewritingNet.UrlRewriter" />
But this had no impact, the error remained. And in another instance the error mentioned a different assembly instead of UrlRewritingNet.UrlRewriter
.
回答1:
I got this working by adding ~/api/ to:-
<add key="umbracoReservedPaths" value="~/umbraco,~/install/,~/bundles, ~/api/" />
And then wrapping the following web.config sections of my parent umbraco app with the location tag:-
<location path="." inheritInChildApplications="false">
<system.web>
and
<location path="." inheritInChildApplications="false">
<system.webServer>
来源:https://stackoverflow.com/questions/36853115/umbraco-child-mvc-application-virtual-directory-could-not-load-file-or-assem