ASP.Net Core MVC Sidebar links with Areas

I am creating an ASP.Net Core MVC site using the Metronic v8.1.6 template utilising the Starterkit project.

I am using Areas, and I am trying to figure out how to get the Sidebar links to work.

I am trying to do the equivalent of:

<a class="menu-link" asp-area="HumanResources" asp-controller="Employee" asp-action="Details">

The correct location appears in the Chrome tooltip when I hover over the link, but nothing happens when I click the link.

I have tried changing the url to:

<a class="menu-link" href="?page=/HumanResources/Employee/Details">

but it still doesn't work.

Could you tell me what I'm missing?

Text formatting options
Submit

Replies (7)

Hi,

The first example looks fine, make sure that you are using the correct names in asp-area, asp-controller and asp-action attributes.

Or alternatively, you can just link your page with href attribute.

<a class="menu-link" href="/HumanResources/Employee/Details">

Regards,
Lauris Stepanovs,
Keenthemes Support Team

Hi Lauris,

I have checked the spelling and it is correct.

If I copy the url and paste it in to the address bar then it works as expected, but clicking on the link does nothing.

I have set a breakpoint in the controller method but it does not get hit when clicking the link but it does get hit when entering the url directly into the address bar.

Regards,
Alan

FYI this is how the code looks...

<div data-kt-menu-trigger="click" class="menu-item menu-accordion">
<span class="menu-link">
<span class="menu-icon"><i class="fa-duotone fa-users"></i></span>
<span class="menu-title">Human Resources</span>
<span class="menu-arrow"></span>
</span>

<div class="menu-sub menu-sub-accordion">
<div data-kt-menu-trigger="click" class="menu-item menu-accordion">
<span class="menu-link">
<a class="menu-link" asp-area="HumanResources" asp-controller="Employee" asp-action="Details">
<span class="menu-bullet">
<span class="bullet bullet-dot"></span>
</span>
<span class="menu-title">Employee Details</span>
</a>
</span>
</div>
</div>
</div>

Hi,

Can you try to use the link below?

<a class="menu-link" href="/HumanResources/Employee/Details">

Regards,
Lauris Stepanovs,
Keenthemes Support Team

Hi Lauris,

Clicking this version of the link still doesn't work, but pasting it into the address bar does.

Regards,
Alan

Hi Lauris,

I have overhauled all the menu links and they now appear to be working. I guess there must have been a typo in there that I hadn't spotted earlier.

Thank you for your time and patience.

Regards,
Alan

Hi,

Glad to hear that. All the best with your project!

Regards,
Lauris Stepanovs,
Keenthemes Support Team

Text formatting options
Submit
Text formatting options
Submit