Cannot get a new page to work in Nop 4.0

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
4 years ago
I am working on a plugin that would allow our Nop 4.0 site to pull information from our internal systems.  I have a widget that I am attempting to open a page with, and I keep getting page not found.  I would appreciate any comments.

Here is plugin logic that shows the button on page.

@model Nop.Plugin.AMT.Lion.Models.PublicInfoModel
@{
    Layout = "";
}

<div>

    <a href="AMTController/Backorder">
        <input type="button" value="Backorder" />
    </a>
    <a asp-controller="AMTController" asp-action="Backorder">Click Me</a>
    <a asp-controller="AMTController" >Index</a>
</div>

Here is BackorderModel.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Nop.Web.Framework.Mvc.Models;

namespace Nop.Plugin.AMT.Lion.Models
{
    public class BackorderModel : BaseNopModel
    {
    }
}

Here is Backorder view.

@model Nop.Plugin.AMT.Lion.Models.BackorderModel

@inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage<TModel>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Nop.Web.Framework

@using Microsoft.AspNetCore.Mvc.ViewFeatures
@using Nop.Web.Framework.UI
@using Nop.Web.Framework.Extensions
@using System.Text.Encodings.Web

@{
    Layout = "_ColumnsOne.cshtml";
}
<table class="bkor-table" cellspacing="2" cellpadding="1" border="0">
    <thead>table header row</thead>
</table>


Here is Backorder controller.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Nop.Core;
using Nop.Core.Caching;
using Nop.Plugin.AMT.Lion.Models;
using Nop.Services.Configuration;
using Nop.Services.Localization;
using Nop.Services.Media;
using Nop.Services.Security;
using Nop.Services.Stores;
using Nop.Web.Framework;
using Nop.Web.Framework.Controllers;
using Nop.Web.Framework.Mvc.Filters;

namespace Nop.Plugin.AMT.Lion.Controllers
{
    public class AMTController : Controller
    {
        public ActionResult Backorder()
        {
            return View("~/Plugins/Widgets.AmtLion/Views/Backorder.cshtml");
        }
    }
}

And I added a route -
// AMT BKOR page
            routeBuilder.MapLocalizedRoute("AMTController", "Backorder",
                new { controller = "AMTController", action = "Backorder" });

When I click the button, the url shows as - http://testserv2.mebulbs.com/AMTController/Backorder

Why is the blank page not showing?
4 years ago
Hello,

Follow this register route https://demo.nopcommerce.com/register if you want to open page from plugin.

It will help you to configure your route properly.

If you want to work with widget than you should look at nivo slider plugin.

still you are facing issue than let me know i will guide you.

Thanks
4 years ago
Does issue have to do with using BasePublicController instead of Controller?

I am not following your suggestions very well.
4 years ago
Artdtc wrote:
When I click the button, the url shows as - http://testserv2.mebulbs.com/AMTController/Backorder
You have to use @Html.RouteURL instead of direct
  [code]href="AMTController/Backorder"
or
asp-controller="AMTController" asp-action="Backorder"

First you need to update you route
Give proper route name, so let assume it is AMTBackorder
So route code would be like this
// AMT BKOR page
routeBuilder.MapLocalizedRoute("AMTBackorder", "backorder",
   { controller = "AMTController", action = "Backorder" });

Now your button html code shoule be like this
 <a href="@Url.RouteUrl("AMTBackorder")">Click Me or Back Order</a>

This will redirect to you
www.yourstore.com/backorder

I hope this helps you resolve your problem.
4 years ago
Not sure why this is so hard to get working.
Inside the plugin -
The view has two different example of links, these do show on the home page.
<a href="@Url.RouteUrl("AMTBackorder")">Backorder</a>
<a asp-controller="AMTController" asp-action="Backorder">Click Me</a>

The controller contains -
namespace Nop.Plugin.AMT.Lion.Controllers
{
    public class AMTController : Controller
    {
        public ActionResult Backorder()
        {
            return View("~/Plugins/Widgets.AmtLion/Views/Backorder.cshtml");
        }
    }
}

The route contains -
// AMT BKOR page
            routeBuilder.MapLocalizedRoute("AMTBackorder", "backorder",
              new { controller = "AMTController", action = "Backorder" });

The URL in browser shows - http://testserv2.mebulbs.com/backorder

The view is defined n /Plugins/Widgets.AmtLion/Views/Backorder.cshtml

Backorder.chstml contains -
@model Nop.Plugin.AMT.Lion.Models.BackorderModel

@inherits Nop.Web.Framework.Mvc.Razor.NopRazorPage<TModel>
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, Nop.Web.Framework

@using Microsoft.AspNetCore.Mvc.ViewFeatures
@using Nop.Web.Framework.UI
@using Nop.Web.Framework.Extensions
@using System.Text.Encodings.Web

@{
    Layout = "_ColumnsOne.cshtml";
}
<table class="bkor-table" cellspacing="2" cellpadding="1" border="0">
    <thead>table header row</thead>
</table>

Is there a issue with calling a page from a plugin?
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.