Error when calling a view form a controller which is inside my plguin

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 years ago
I've got an error that is driving me crazy, specially because it is something VERY small that I am missing.
I have a plugin which has views and controllers. I've added the route and the controller is being called perfectly

I have this folder tree:
root
-Controller
-Views
  -MyController
      -Index.cshtml

In my controller, the index action (which is correctly called):

        public ActionResult Index()
        {
            return View("Nop.Plugin.MyPluginViews.MyController.Index");
        }

But I am getting the following error:
The view 'Nop.Plugin.MyPluginViews.MyController.Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Themes/MyTheme/Views/MyController/Nop.Plugin.MyPluginViews.MyController.Index
....... (many other locations)

Any idea why this could be happening?

thanks,
Oscar


Never mind: setting the views as embedded resource solved it :)
11 years ago
oscarfh wrote:
I've got an error that is driving me crazy, specially because it is something VERY small that I am missing.
I have a plugin which has views and controllers. I've added the route and the controller is being called perfectly

I have this folder tree:
root
-Controller
-Views
  -MyController
      -Index.cshtml

In my controller, the index action (which is correctly called):

        public ActionResult Index()
        {
            return View("Nop.Plugin.MyPluginViews.MyController.Index");
        }

But I am getting the following error:
The view 'Nop.Plugin.MyPluginViews.MyController.Index' or its master was not found or no view engine supports the searched locations. The following locations were searched:
~/Themes/MyTheme/Views/MyController/Nop.Plugin.MyPluginViews.MyController.Index
....... (many other locations)

Any idea why this could be happening?

thanks,
Oscar


Never mind: setting the views as embedded resource solved it :)




If your view is not embedded in Plugin then you can use only name for return view from Plugin Controller to View which is inside the nop.web/views/myController. Following code will solve your problem.

            return View("Index");
7 years ago
I Had this issue recently

In your Plugin Description.txt

Here SystemName should match while returning the view name

SystemName: MyFeature.MyCustomPluginName

Wrong With "Nop.Plugin." :

           return View("~/Plugins/Nop.Plugin.MyFeature.MyCustomPluginName/Views/MyController/Configure.cshtml", model);

Correct Without "Nop.Plugin."

           return View("~/Plugins/MyFeature.MyCustomPluginName/Views/MyController/Configure.cshtml", model);


You can also check already available plugin like mail chimp etc to get an idea.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.