A stupid mistake like not override the FileExist method made this not working.
Custom RazorViewEngin don't execute overriden CreateView
-
21-07-2023 - |
Vra
I'm trying to create a custom view engine to look for views based on a specific virtual path based on modulen ame/assembly name. The plan is to be able to install modules containing their own separate views and controllers.
I have a structure to load and configure things when my application starts upp. In my MVC Initializer module i clear all view engines and then add my own custom view engine.
However the overriden CreateView never execute when i navigate to a controller action. Findview do execute and i currently just return base.FindView(..., ..., ...).
My current class inherit RazorViewEngine and i set my new strings for all locations based on my needs and using %1 as my assembly name holder in those strings. In my CreateView i then replace %1 with the assembly name of the controller.
The work is based on the information from http://weblogs.asp.net/imranbaloch/archive/2011/06/27/view-engine-with-dynamic-view-location.aspx.
But as i said the problem is create view never executed so it never finds a view since the view locations contains %1 and not the assembly name.
Worth mentioning is i run a asp.net MVC 5, c# .NET 4/4.5 site.
Oplossing