Add-on not finding Razor templates

Vote:
 

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?

#69591
Mar 28, 2013 14:46
Vote:
 

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.

#69626
Mar 31, 2013 23:16
Vote:
 

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.

#69645
Apr 02, 2013 8:49
Vote:
 

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.

 

 

#73386
Jul 17, 2013 11:01
Vote:
 

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 :(

 

#73541
Jul 26, 2013 13:00
Vote:
 

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.

#179163
Jun 01, 2017 15:09
Vote:
 

http://marisks.net/2017/03/19/enable-razor-views-in-episerver-modules-with-shellrazorsupport-package/

#179164
Jun 01, 2017 15:16
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.