Couldn't find plugin view using Custom View Engine

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
7 years ago
I am trying to overide product catalog category page using Custom View Engine by following @Woon article using this link : https://www.pronopcommerce.com/3-ways-to-display-views-in-your-nopcommerce-plugins-embedded-resource-theme-override-and-custom-view-engine

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 ?
7 years ago
Make sure your Plugin\s folder Name "Nop.Plugin.Testing.Example". See from Nop.Web=>Plugins folder

And also make sure  view has in the following path ==>

/Plugins/Nop.Plugin.Testing.Example/Views/Example/AboutPlugin.cshtml
7 years ago
sohel wrote:
Make sure your Plugin\s folder Name "Nop.Plugin.Testing.Example". See from Nop.Web=>Plugins folder

And also make sure  view has in the following path ==>

/Plugins/Nop.Plugin.Testing.Example/Views/Example/AboutPlugin.cshtml


Hi sohel, thanks for the reply , here is my setup.

View In Nop Root ==> Plugins Folder

Name: Nop.Plugin.Testing.Example

/Plugins/Nop.Plugin.Testing.Example/Views/Example/AboutPlugin.cshtml


Build View In Nop.Web ==>  Plugins Folder


Name: Testing.Example


/Plugins/Testing.Example/Views/Example/AboutPlugin.cshtml

OutPut Path

..\..\Presentation\Nop.Web\Plugins\Testing.Example\
7 years ago
sohel wrote:
Make sure your Plugin\s folder Name "Nop.Plugin.Testing.Example". See from Nop.Web=>Plugins folder

And also make sure  view has in the following path ==>

/Plugins/Nop.Plugin.Testing.Example/Views/Example/AboutPlugin.cshtml



Thank you sohel. You were correct.


I changed Plugin OutPut Path

From

..\..\Presentation\Nop.Web\Plugins\Testing.Example\


To


..\..\Presentation\Nop.Web\Plugins\Nop.Plugin.Testing.Example\

Now view is rendered correctly.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.