Umbraco Child MVC Application (Virtual Directory) - Could not load file or assembly Umbraco.ModelsBuilder

淺唱寂寞╮ 提交于 2019-12-25 04:41:17

问题


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:

  1. Created a brand new empty ASP.NET solution/project
  2. Added the UmbracoCms nuget package (7.4.3)
  3. Built the solution
  4. Setup my IIS Site - "UmbracoDemo" with host name umbraco-demo.local
  5. 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..

  1. Created a new ASP.NET MVC application in a new VS solution called "DemoApp"
  2. Built the new solution and ran it immediately with IIS Express -- the MVC app works correctly
  3. In IIS Manager, I right-clicked my UmbracoDemo site and added an "Application" called "DemoApp", pointing it to the DemoApp MVC project directory
  4. Added "~/DemoApp" to the umbracoReservedPaths setting in Umbraco's web.config
  5. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!