Embeded views not working in MVC 5 #1153

Imported from the CodePlex archive for reference purposes. Support for MvcCodeRouting has ended.

Reported on

I upgrade my MVC4 project to MVC 5. I have problem with embedded views witch is not founded. When MVC try to find view it calls MvcCodeRouting.Web.Mvc.ViewEngineWrapper.FindPartialView -> FindView -> wrappedEngine.FindPartialView witch not call EmbeddedViewsVirtualPathProvider.FileExists. I check wrappedEngine and it has VirtualPathProvider set to EmbeddedViewsVirtualPathProvider. And when I try to find view witch is local (standard file exists) method EmbeddedViewsVirtualPathProvider.FileExists is called.

Does anyone know what is wrong with MVC 5?

Thanks

Commented on link

Maybe I found why it not use EmbeddedViewsVirtualPathProvider. In MVC 5 there is two ViewEngines RazorViewEngine and WebFormViewEngine both inherits from abstract class BuildManagerViewEngine. This class overrides FileExists method from base class VirtualPathProviderViewEngine. Inside method is used FileExistenceCache instantiated in constructor but with MapPathBasedVirtualPathProvider.

Commented on link

Thanks for reporting this issue. I was able to reproduce and found the cause of the problem. The new FileExistenceCache class in MVC 5 is getting the VirtualPathProvider from HostingEnvironment.VirtualPathProvider before MvcCodeRouting is setting EmbeddedViewsVirtualPathProvider. Need to figure out the best way to fix this, because what triggers FileExistenceCache is using ViewEngines.Engines, and there’s no way to control 3rd party code from using it before we do.

Commented on link

There’s already a bug report on MVC. Please vote so they fix this.