My problem is that when i am not in my "Admin" area the link shows up as "/blog" however when i am in my "Admin" area the link turns to "/admin/blog".
I have an "Admin" area and i have specified a layout page in a viewstart file in the "Admin" area View section. Markup below:
Layout = "~/Views/Shared/_Layout.cshtml";
The markup of my link looks like this (this link is in my _Layout.cshtml view):
<a asp-controller="Blog" asp-action="Index" class="nav-link"> Blog </a>
My routes look like this:
app.UseMvc(routes =>
{
routes.MapRoute(
name: "default",
template: "{controller=Home}/{action=Index}/{id?}");
});
app.UseMvc(routes =>
{
routes.MapRoute(
name: "areas",
template: "{area:exists}/{controller=Home}/{action=Index}/{id?}"
);
});
And my controller in my "Admin" area looks like this:
[Authorize(Roles = "Admin")]
[Area("Admin")]
public class ProductsController : Controller
I have tried adding asp-area="" so my a tag would look like :
<a asp-area="" asp-controller="Blog" asp-action="Index" class="nav-link"> Blog </a>
But this just leaves the href empty when looking at it through developer tools.
So my question is how can i remove the area name from the url?
I feel like it is something really easy but i cannot figure it out. I have looked at this thread but it is not in .net core so the solution does not work.