MVC SportsStore:[Building a Category Navigation Menu]
I've been following Steven Sanderson's book called Pro ASP.NET MVC Framework, and I'm running into an exception:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0121: The call is ambiguous between the following methods or properties: 'Microsoft.Web.Mvc.ViewExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string)' and 'System.Web.Mvc.Html.ChildActionExtensions.RenderAction(System.Web.Mvc.HtmlHelper, string, string)'
Line 15: </div>
Line 16: <div id="catagories">
Line 17: <% Html.RenderAction("Menu", "Nav"); %>
Line 18: </div>
Line 19: <div id="content">
My Site.Master code:
<body>
<div id="header">
<div class="title">
SPORT STORE</div>
</div>
<div id="catagories">
<% Html.RenderAction("Menu", "Nav"); %>
</div>
<div id="content">
<asp:ContentPlaceHolder ID="MainContent" run开发者_如何学JAVAat="server" />
</div>
</body>
I thank I Know where is wrong. When I change Microsoft.Web.Mvc.dll of MVC1 to Microsoft.Web.Mvc.dll of MVC2, this error is solved. But it appear other error:
Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.
Compiler Error Message: CS0234: The type or namespace name 'NavLink' does not exist in the namespace 'WebUI.Controllers' (are you missing an assembly reference?)
Source Error:
Line 170:
Line 171: [System.Runtime.CompilerServices.CompilerGlobalScopeAttribute()]
Line 172: public class views_nav_menu_ascx : System.Web.Mvc.ViewUserControl<IEnumerable<WebUI.Controllers.NavLink>> {
Line 173:
Line 174: private static bool @__initialized;
So, How can I do now?
On Chapter 5, Page 137:
<%@ Control Language="C#"
Inherits="System.Web.Mvc.ViewUserControl
<IEnumerable<WebUI.Controllers.NavLink>>" %>
Didn't work for me. I kept getting: The type or namespace name 'NavLink' does not exist in the namespace 'WebUI.Controllers'
I had to change "... Controllers.NavLink..." to "... Controllers.NavController.NavLink..." in order for it to work. Like this:
<%@ Control Language="C#"
Inherits="System.Web.Mvc.ViewUserControl
<IEnumerable<WebUI.Controllers.NavController.NavLink>>" %>
精彩评论