2

I'm having trouble with getting nested (sub) Areas to work with Razor Pages. I would like to have a route structure like this:

/Index
/Admin
/Admin/Orders
/Admin/Inventory

My current file structure is the following:

/Pages
  /Index.cshtml
/Areas
  /Admin
    /Inventory
      /Pages
        /Index.cshtml
      /Models
    /Orders
      /Pages
        /Index.cshtml
      /Models
  /Product
    /Models
    /Pages

My Admin.Index page:

@page
@model ECommerceWeb.Areas.Admin.Pages.AdminModel
@{
    ViewData["Title"] = "Admin";
}

<h2>Admin</h2>

<ul>
    <li><a asp-page="Index" asp-area="Inventory">Inventory</a></li>
    <li><a asp-page="/Orders/Orders" asp-area="Admin">Orders</a></li>
</ul>

<form method="post">
    <button type="submit" name="action" value="logoutButton">Logout</button>
</form>

As you can see from the two <a> tags above, I've tried various approaches.

1 Answer 1

4

I solved this by re-structuring my application/folder structure to look like:

/Pages
  /Index.cshtml
/Areas
  /Admin
    /Models
      /Inventory
      /Orders
    /Pages
      /Inventory
        /Index.cshtml
      /Orders
        /Index.cshtml
  /Product
    /Models
    /Pages
      /Index.cshtml
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.