Inhalte aufrufen

Profilbild

Plugin Entwicklung - View wird nicht gefunden


  • Bitte melden Sie sich an, um eine Antwort zu verfassen.
3 Antworten zu diesem Thema

#1 qtrado-mt

qtrado-mt

    Newbie

  • Members
  • 5 Beiträge

Geschrieben: 25 October 2021 - 10:37

Hallo,

 

ich hänge leider wieder an einem Problem.

 

Ich möchte eine neue Entität anzeigen lassen.

 

Die zugehörige View wird aber nicht gefunden.
Die Fehlermeldung lautet:

[InvalidOperationException: Die Ansicht "grossistall" oder die entsprechende Gestaltungsvorlage wurde nicht gefunden, oder keines der Ansichtsmodule unterstützt die durchsuchten Speicherorte. Die folgenden Speicherorte wurden durchsucht:
~/Administration/Views/grossist/Layouts/grossistall.cshtml
~/Administration/Views/grossist/grossistall.cshtml
~/Administration/Views/Shared/Layouts/grossistall.cshtml
~/Administration/Views/Shared/grossistall.cshtml
~/Plugins/Admin/Views/grossist/Layouts/grossistall.cshtml
~/Plugins/Admin/Views/grossist/grossistall.cshtml
~/Plugins/Admin/Views/Shared/Layouts/grossistall.cshtml
~/Plugins/Admin/Views/Shared/grossistall.cshtml
~/Themes/Flex/Views/grossist/Layouts/grossistall.cshtml
~/Themes/Flex/Views/grossist/grossistall.cshtml
~/Views/grossist/Layouts/grossistall.cshtml
~/Views/grossist/grossistall.cshtml
~/Themes/Flex/Views/Shared/Layouts/grossistall.cshtml
~/Themes/Flex/Views/Shared/grossistall.cshtml
~/Views/Shared/Layouts/grossistall.cshtml
~/Views/Shared/grossistall.cshtml]
System.Web.Mvc.ViewResult.FindView(ControllerContext context) +382
System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +116
System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) +13
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +56
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +420
System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +52
System.Web.Mvc.Async.<>c__DisplayClass3_6.<BeginInvokeAction>b__4() +198
System.Web.Mvc.Async.<>c__DisplayClass3_1.<BeginInvokeAction>b__1(IAsyncResult asyncResult) +100
System.Web.Mvc.Async.WrappedAsyncResult`1.CallEndDelegate(IAsyncResult asyncResult) +10
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +27
System.Web.Mvc.<>c.<BeginExecuteCore>b__152_1(IAsyncResult asyncResult, ExecuteCoreState innerState) +11
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +45
System.Web.Mvc.<>c.<BeginExecute>b__151_2(IAsyncResult asyncResult, Controller controller) +13
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +22
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +26
System.Web.Mvc.Controller.System.Web.Mvc.Async.IAsyncController.EndExecute(IAsyncResult asyncResult) +10
System.Web.Mvc.<>c.<BeginProcessRequest>b__20_1(IAsyncResult asyncResult, ProcessRequestState innerState) +28
System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase`1.End() +49
System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +28
System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) +9
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +577
System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step) +132
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +163

Ich habe zunächst einen Controller (GrossistController) erstellt und darin eine Methode GrossistAll() implementiert.

 

namespace QTRADO.WMAddOn.Controllers
{
    public class GrossistController : AdminControllerBase
    {
       ...


        #region List


        [RewriteUrl(SslRequirement.No)]
        public ActionResult GrossistAll()
        {
            var model = new List<GrossistModel>();
            var grossists = _grossistService.GetAllGrossists(null, false);
                        


            foreach (var grossist in grossists)
            {
                var grossistModel = grossist.ToModel();
                model.Add(grossistModel);
            }


            Services.DisplayControl.AnnounceRange(grossists);


            //ViewBag.SortGrossistsAlphabetically = _grossistsSettings.SortManufacturersAlphabetically;


            return View(model);
        }

 

Eine View mit dem Namen GrossistAll.cshtml befindet sich im Verzeichnis .\Views\grossist des Plugin-Projektes.

 

 

Dann habe ich noch den Menüeintrag in der AdminMenu.cs erstellt:

 

namespace QTRADO.WMAddOn
{
    public class AdminMenu : AdminMenuProvider
    {
        protected override void BuildMenuCore(TreeNode<MenuItem> pluginsNode)
        {
                        
            var menuItem = new MenuItem().ToBuilder()
                .Text("Werbemittel AddOn")
                .ResKey("Plugins.FriendlyName.QTRADO.WMAddOn")
                .Icon("far fa-images")
                .PermissionNames(WMAddOnPermissions.Read)
                .Action("ConfigurePlugin", "Plugin", new { systemName = "QTRADO.WMAddOn", area = "Admin" })
                .ToItem();


            pluginsNode.Prepend(menuItem);


            var userNode = pluginsNode.Root.SelectNodeById("users");
            
            var menuItemGrossist = new MenuItem().ToBuilder()
                .Text("Grossisten")
                .ResKey("Admin.Customer.Grossist.Menu")
                .Icon("far fa-images")
                .PermissionNames(WMAddOnPermissions.Grossist.Read)                
                .Action("GrossistAll","Grossist", new { area = "Admin" })
                .ToItem();
            userNode.Prepend(menuItemGrossist, "grossistList");
        }

Hier noch der Link zum Repositiory: https://github.com/q...t/SmartStoreNET

 

Meine Frage, warum wird die View GrossistAll nicht gefunden ?

Offensichtlich wird ja der Pfad in dem die View liegt nicht durchsucht.

 



#2 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3670 Beiträge

Geschrieben: 25 October 2021 - 15:22

Kann es daran liegen, dass der Ordnername klein geschrieben wurde, also "grossist" anstatt "Grossist"?


Schöne Grüße aus Düsseldorf,
Marcus Gesing


#3 qtrado-mt

qtrado-mt

    Newbie

  • Members
  • 5 Beiträge

Geschrieben: 26 October 2021 - 07:58

Daran lag es nicht. Der Ordnername war zwar klein geschrieben, die Umbenennung hat aber nichts geändert.

Wenn ich den Pfad zur View explizit angebe  wird diese gefunden.

 return View("~/Plugins/QTRADO.WMAddOn/Views/Grossist/GrossistAll.cshtml",model);


#4 Marcus Gesing

Marcus Gesing

    SmartStore AG

  • Administrators
  • 3670 Beiträge

Geschrieben: 26 October 2021 - 11:20

Benötigt die Action-Methode das AdminThemed Attribut wie hier zu sehen?


Schöne Grüße aus Düsseldorf,
Marcus Gesing