MVC Route Tracing

Hi everyone, new to asp.net mvc, and I am creating a fake social site (for training purposes), creating an mvc template for stocks ... I added some views, etc. that all work fine. However, now I have added the mvc area called "Blog" and added the link to the main menu. Now, if I click on any of the menu items, everything works as expected. However, when I click on the menu item "Blog", view, etc. Display a blog page, however menu links for other views have / Blog / in front of the URL now !? Not sure if I am doing something wrong ... here is my menu code:

<div id="menucontainer">
                <ul id="menu">
                    @* @Html.ActionLink() Params = String Name, String Controller Name,
                    string Method (actionLink) Name *@
                    <li>@Html.ActionLink("Home", "Index", "Home")</li>
                    <li>@Html.ActionLink("Mail", "Index", "Mail")</li>
                    <li>@Html.ActionLink("Search", "Index", "Search")</li>
                    <li>@Html.ActionLink("Dating", "Index", "Dating")</li>
                    <li>@Html.ActionLink("Groups", "Index", "Groups")</li>
                    <li>@Html.ActionLink("Forums", "Index", "Board")</li>
                    <li>@Html.ActionLink("Blog", "Index", "Blog")</li>
                    <li>@Html.ActionLink("About", "About", "Home")</li>
                </ul>
            </div>
+3
source share
2 answers

, MVC , , URL. , ActionLink "Area". , "" "" , :

@Html.ActionLink("Dating", "Index", new { controller = "Dating", area = "Social" } );

ASP.NET MVC 2:

"Area"

"Area" ASP.NET MVC, , "" "". , HTML- , "area", "Area" .

Areas, {area} URL .

+3

undefined . , @Html.ActionLink("Test", "Test") . , Foo, <a href="/Foo/Test">Test</a>. - , , . : @Html.ActionLink("Test", "Test", "Foo", new { @area = string.Empty }, null) Foo action Test .

+1

Source: https://habr.com/ru/post/1793186/


All Articles