Do we still use _AdminLayout.cshtml in plugins?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
6 years ago
In my List.cshtml in my plugin do we still use
Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
? I have:

@using Nop.Core.Domain.Common;

@inject AdminAreaSettings adminAreaSettings


When I do I get:

An unhandled exception occurred while processing the request.

InvalidOperationException: The view 'Components/AdminLanguageSelector/Default' was not found. The following locations were searched:
/Themes/DefaultClean/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Themes/DefaultClean/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions+<>c.<UseNopExceptionHandler>b__1_1(HttpContext context) in ApplicationBuilderExtensions.cs, line 81

Stack Query Cookies Headers
InvalidOperationException: The view 'Components/AdminLanguageSelector/Default' was not found. The following locations were searched:
/Themes/DefaultClean/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Themes/DefaultClean/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions+<>c.<UseNopExceptionHandler>b__1_1(HttpContext context) in ApplicationBuilderExtensions.cs
+
                        throw exception;
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+<Invoke>d__6.MoveNext()
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+<Invoke>d__6.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+<Invoke>d__7.MoveNext()

Show raw exception details
System.InvalidOperationException: The view 'Components/AdminLanguageSelector/Default' was not found. The following locations were searched:
/Themes/DefaultClean/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Themes/DefaultClean/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.<>c.<UseNopExceptionHandler>b__1_1(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()
6 years ago
dootchie wrote:
In my List.cshtml in my plugin do we still use
Layout = "~/Areas/Admin/Views/Shared/_AdminLayout.cshtml";
? I have:

@using Nop.Core.Domain.Common;

@inject AdminAreaSettings adminAreaSettings


When I do I get:

An unhandled exception occurred while processing the request.

InvalidOperationException: The view 'Components/AdminLanguageSelector/Default' was not found. The following locations were searched:
/Themes/DefaultClean/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Themes/DefaultClean/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions+<>c.<UseNopExceptionHandler>b__1_1(HttpContext context) in ApplicationBuilderExtensions.cs, line 81

Stack Query Cookies Headers
InvalidOperationException: The view 'Components/AdminLanguageSelector/Default' was not found. The following locations were searched:
/Themes/DefaultClean/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Themes/DefaultClean/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions+<>c.<UseNopExceptionHandler>b__1_1(HttpContext context) in ApplicationBuilderExtensions.cs
+
                        throw exception;
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+<Invoke>d__6.MoveNext()
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware+<Invoke>d__6.MoveNext()
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware+<Invoke>d__7.MoveNext()

Show raw exception details
System.InvalidOperationException: The view 'Components/AdminLanguageSelector/Default' was not found. The following locations were searched:
/Themes/DefaultClean/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Themes/DefaultClean/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
/Views/Fundraiser/Components/AdminLanguageSelector/Default.cshtml
/Views/Shared/Components/AdminLanguageSelector/Default.cshtml
   at Nop.Web.Framework.Infrastructure.Extensions.ApplicationBuilderExtensions.<>c.<UseNopExceptionHandler>b__1_1(HttpContext context)
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware.<Invoke>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.<Invoke>d__7.MoveNext()


Try like  bellow ===>


[Area(AreaNames.Admin)]
    public class YourController : BasePluginController
    {
....
}


Then in view ==>

Layout = "_AdminLayout";
6 years ago
woo that got me closer, now i'm getting Page not found :) always something. Here is my route, I think I'm doing it the new way:

public void RegisterRoutes(IRouteBuilder routeBuilder)
        {
            routeBuilder.MapLocalizedRoute("Plugin.TShirts.Fundraiser", "Admin/Plugins/Shirt/Fundraiser/{action}/{id}",
                 new { controller = "Fundraiser", action = "Index", id = "" });
        }
6 years ago
dootchie wrote:
woo that got me closer, now i'm getting Page not found :) always something. Here is my route, I think I'm doing it the new way:

public void RegisterRoutes(IRouteBuilder routeBuilder)
        {
            routeBuilder.MapLocalizedRoute("Plugin.TShirts.Fundraiser", "Admin/Plugins/Shirt/Fundraiser/{action}/{id}",
                 new { controller = "Fundraiser", action = "Index", id = "" });
        }


I think you don't need to write new route ==>

Just call ==> "/Admin/Fundraiser/YourActionName/{id}" .. It will hit to your action too.

I mean ==> <a href="/Admin/Fundraiser/YourActionName/{id}" > TextForLink </a> will work for you too.


and "Fundraiser" you can put here any controller name too
6 years ago
sohel wrote:
woo that got me closer, now i'm getting Page not found :) always something. Here is my route, I think I'm doing it the new way:

public void RegisterRoutes(IRouteBuilder routeBuilder)
        {
            routeBuilder.MapLocalizedRoute("Plugin.TShirts.Fundraiser", "Admin/Plugins/Shirt/Fundraiser/{action}/{id}",
                 new { controller = "Fundraiser", action = "Index", id = "" });
        }


I think you don't need to write new route ==>

Just call ==> "/Admin/Fundraiser/YourActionName/{id}" .. It will hit to your action too.

I mean ==> <a href="/Admin/Fundraiser/YourActionName/{id}" > TextForLink </a> will work for you too.


and "Fundraiser" you can put here any controller name too


You're a life saver! I wish I could give you a hug!! Everything you've suggested has worked and I'm on way way to validating my plugins!!! Thank you so much
6 years ago
Hi,

Once i put [Area(AreaNames.Admin)] over the controller or the method, i got "Page not found" exception! If i removed it, the method is called but the _adminlayout is not found!. I have a link in the admin configured as below:

            SiteMapNode pluginNode = new SiteMapNode();
            pluginNode.Title = this._localizationService.GetResource("MyPlugin");
            pluginNode.Url = "~/Admin/Plugins/xxx/Configure";
            pluginNode.Visible = true;
            pluginNode.IconClass = "fa-dot-circle-o";
            pluginNode.RouteValues = new RouteValueDictionary()
            {
                { "Namespaces", "xxx" },
                { "area", "admin" }
            };


Please advise
6 years ago
ahmadkq wrote:
Hi,

Once i put [Area(AreaNames.Admin)] over the controller or the method, i got "Page not found" exception! If i removed it, the method is called but the _adminlayout is not found!. I have a link in the admin configured as below:

            SiteMapNode pluginNode = new SiteMapNode();
            pluginNode.Title = this._localizationService.GetResource("MyPlugin");
            pluginNode.Url = "~/Admin/Plugins/xxx/Configure";
            pluginNode.Visible = true;
            pluginNode.IconClass = "fa-dot-circle-o";
            pluginNode.RouteValues = new RouteValueDictionary()
            {
                { "Namespaces", "xxx" },
                { "area", "admin" }
            };


Please advise


See the post
Hope it will help you.

And write the Url ==> pluginNode.Url = "~/Admin/YourControllerName/Configure"; intstead "~/Admin/Plugins/xxx/Configure";
6 years ago
Hope this help...

Here is my "page" code


Here is my "views" layout


Here is my "controller" code



Then i removed my "RouteProvider.cs" completely and it goes to /Admin/Fundraiser/List
6 years ago
I is working now. You need to use your controller/action and not to specify a route while you are in the admin area (decorated with admin attribute). Thank you all
6 years ago
Great I'm glad it works!!

So if we want to display a page in a customers "my account" we need a component to do that? Do we need a routeprovider.cs then?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.