0

This .cshtml page display the main menu:

MyMVCProject\Location\Subjects\Views\@_MyMainMenu.cshtml

And, this .cshtml displays all classrooms data:

MyMVCProject\Views\Classrooms\@_Index.cshtml

I have added a menu item in @_MyMainMenu.cshtml named "Classrooms". Using ASP.NET MVC 5, how do I get this new menu item to call Classrooms\@_Index.cshtml to displays all classrooms data?

TIA

3
  • You don't call a view - what you do is call an action method, which then renders a view. So in your case - you need to have an action method on your ClassroomsController which you can call, which then renders the Index view for the classrooms Commented Jun 18, 2024 at 3:45
  • I use something like <li>@Html.ActionLink("Classroom", "Index", "MyViewFolder")</li> if controllers and views are in the same top level folder. How do achieve the same if controllers and views are in a different top level folder? Commented Jun 18, 2024 at 4:43
  • I get the following error. The Controller "My" is in a different location (MyProject\Controllers, not under "City" (MyProject\Location\City\Controllers) Server Error in '/' Application. The resource cannot be found. __Description:__HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable. Please review the following URL and make sure that it is spelled correctly. Requested URL:/City/My Commented Jun 18, 2024 at 19:07

0

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.