skip to Main Content

I’m currently developing an asp.net core web app, and I’m struggling on correctly navigating through the app.

Here is my directory structure, note that I’m using Areas.

1st part
2nd part

Now, the exact problem is that I’m able to navigate through the pages that are in the main folder like Index, Index1 and Private, but once I go to the Area, I am no longer able tonavigate correctly.

It is remarkable to say that the Layout code of the _Layout and _LaunchLayout is almost the same, only changes the name of the navigation items and their destinations.

Once I click any item on the navigation bar to navigate, the corresponding page shows up but the navigation bar disappears.

I’d appreciate some help on this, thanks to you all beforehand.


EDIT: Link to the project

https://github.com/Rogeraj2001/GraphicProofOfConcept.git

2

Answers


  1. Chosen as BEST ANSWER

    Well, after trying some things I found a workaround. That has been to specify the view route in the controller action:

    public IActionResult _ViewStart() {
        return View("~/Areas/LaunchArea/Views/_ViewStart.cshtml");
    }
    

  2. _ViewStart.cshtml file should be in root view folder Views/_ViewStart.cshtml not the Views/Shared folder, So move your _ViewStart.cshtml file out of shared folder:

    enter image description here

    Then modify the code to

    @{
        Layout = "~/Areas/LaunchArea/Views/Shared/_LaunchLayout.cshtml";
    }
    

    Now the area can load layout page successfully.

    enter image description here

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search