Steps used to create Custom View Engine
1. Created Class named CustomViewEngine which inherits ThemeableRazorViewEngine
public class CustomViewEngine: ThemeableRazorViewEngine
{
public CustomViewEngine()
{
ViewLocationFormats = new[]
{
"~/Plugins/Nop.Plugin.Testing.Example/Views/{1}/{0}.cshtml"
};
PartialViewLocationFormats = new[]
{
"~/Plugins/Nop.Plugin.Testing.Example/Views/{1}/{0}.cshtml"
};
}
}
2. Register CustomViewEngine using RouteProvider.cs class in my plugin
System.Web.Mvc.ViewEngines.Engines.Insert(0,new CustomViewEngine());
3. Right click View Properties Select Bulid Action as Content and Copy to Output Directory as Copy always
4. Copy the web.config from Views folder to Plugins Views folder , Select Bulid Action as Content and Copy to Output Directory as Copy always
My View Folder Structure
Nop.Plugin.Testing.Example -- Plugin Class Library Project
Views Folder
Example -- Controller Name is ExampleController
AboutPlugin.cshtml
I followed the above methods but when i call my action method AboutPlugin
http://localhost:11116/Plugins/Testing/AboutPlugin
the view 'AboutPlugin' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Plugins/Nop.Plugin.Testing.Example/Views/Example/AboutPlugin.cshtml
~/Views/Example/AboutPlugin.cshtml
~/Views/Shared/AboutPlugin.cshtml
But If copy the view with folder to Default nopCommerce Views folder , the view is findable in i.e in this location ~/Views/Example/AboutPlugin.cshtml
What am i missing , why view inside my plugin is not findable ?