asp.net mvc menu,navigateUrl="~/Views/User/Index.aspx'-resource not found
I have created an asp.net MVC ap开发者_C百科plication.I created a asp:menu in the master page and I was trying to include the menu items and the sub menu items.When I tried to include the view pages by NavigateURL=~/Views/Home/Index.aspx,i got an error saying"resource not found". On further research, I found out that I can not give the direct URL's of the view folder.
<asp:Menu ID="Menu1" runat="server" Orientation="Horizontal" StaticDisplayLevels="1" BackColor="Silver" Font-Bold="true" StaticEnableDefaultPopOutImage="false" BorderStyle="None">
<StaticMenuItemStyle CssClass="selected" />
<Items>
<asp:MenuItem Text="Home" NavigateUrl="~/Controllers/HomeController.cs" ></asp:MenuItem>
<asp:MenuItem Text="Users" >
<asp:MenuItem Text="User" NavigateUrl="~/Views/User/Index.aspx"></asp:MenuItem>
<asp:MenuItem Text="User2" NavigateUrl="~/Views/User2/Index.aspx"></asp:MenuItem>
<asp:MenuItem Text="User3" NavigateUrl="~/Views/User3/Index.aspx"></asp:MenuItem>
</asp:MenuItem>
</Items>
</asp:Menu>
- what is the best way to give the URLs?
- If NavigateUrl=/Views/Home/Index.aspx is of no use,what is the use of this other than to provide external urls?
It is not typical to use server controls such as asp:Menu in an ASP.NET MVC application.
I'd recommend you look at http://mvcsitemap.codeplex.com/ for doing site map/navigation "controls" in MVC.
精彩评论