As far as I know currently by default only WebForms view engine is supported for AddOn module. Just take a look at `EPiServer.Shell.Modules.ModuleInitializer' in `GetViewEngine(ShellModule module)' method.
Files .cs|vbhtml in ~/Views/.. are searched by default System.Web.Mvc.RazorViewEngine. Maybe more info could be found in http://dmytroduk.com/techblog/developing-simple-add-on-for-episerver-7-preview.
Make sure your Views folder contains a web.config file that contains references to Razor. You can e.g. create a new MVC4 project from Visual Studio and copy the config file from the Views folder to your Views folder.
There is a problem when creating protected addons with Razor views. The web.config file in /Views folder is ignored when the addon is installed in the virtual folder (and not under /modules as for public addons).
Is there someway to overcome this? For know I think we have to use ASPX-views for MVC controllers when creating protected add-ons.
I haven't been working with addons for a while now, but I remember that I had the same issue as Thomas that the addon's web.config file was completely ignored. This caused problems, since the Razor template couldn't find assemblies that were defined in the "missing" web.config file. In the end I just ended up using ASPX-views, which was pretty awkward after getting used to Razor goodness :(
Hi, everyone,
This seems to not work even nowadays.
I have built this add-on for Episerver Forms and I could make it work almost all the way, except the Razor view never got picked up (no matter what I tried out).
If you grab the add-on code and simply change ascx file with the Razor version and update the Controller, it is not going to work unfortunately.
Then, I checked Episerver.Forms and they have the ascx files, too. it's kinda pitty if it's impossible to have Razor view in protected Add-Ons, I almost forgot how to write inside an ascx :)
Anyways, I am leaving this for someone who is building an add-on to find until it's fixed hopefully or maybe someone knows what I may have done wrong, if this was fixed in the meantime.
I'm developing an add-on using Razor templates, but for some reason Episerver isn't looking for the Razor templates in the add-on Views path. I get the following error:
The view 'index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
/yllapito/Solita.LanguageEditor.UI/Views/LanguageEditor/index.aspx
/yllapito/Solita.LanguageEditor.UI/Views/Shared/index.aspx
/yllapito/Solita.LanguageEditor.UI/Views/LanguageEditor/index.ascx
/yllapito/Solita.LanguageEditor.UI/Views/Shared/index.ascx
~/Views/LanguageEditor/index.cshtml
~/Views/LanguageEditor/index.vbhtml
~/Views/Shared/index.cshtml
~/Views/Shared/index.vbhtml
~/Views/LanguageEditor/index.aspx
~/Views/LanguageEditor/index.ascx
~/Views/Shared/index.aspx
~/Views/Shared/index.ascx
The correct ocation for the Razor template would be /yllapito/Solita.LanguageEditor.UI/Views/LanguageEditor/Index.cshtml. The template is found if I manually specify the path to view in the controller using Paths.ToResource(), but why isn't it found automatically?