views:

100

answers:

1

Hi Guys,

I am new to MVC and I have been following Steven Andersons Pro ASP.Net Mvc 2 framework book but have encountered the following issue.

The following line of code that sits in my site.Master file throws the following error:

<% Html.RenderAction("Menu", "Nav"); %>

{"Error executing child request for handler 'System.Web.Mvc.HttpHandlerUtil+ServerExecuteHttpHandlerAsyncWrapper'."}

The problem seems to be within my Partial View that is trying to render the result of the above code.

The actual error that is out put in the browser is as follows:

Could not load type System.Web.Mvc.ViewUserControl<IEnumerable<WebUI.Models.NavLink>>.

my partial view consists of the following:

<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<IEnumerable<WebUI.Models.NavLink>>" %>
<%foreach (var link in Model) { %>
<%: Html.RouteLink(link.Text, link.RouteValues }%>

There also seems to be no IntelliSense available for for the Model.

I know it has something to do with the Inheritance but I have checked the namespace and this appears to be correct.

Any help on this would be much appreciated.

Thanks in advance

A: 

I've gotten Anderson's examples working from the first edition of that book. One thing I noticed is that my NavLink is defined in Controllers/NavController.cs and has a namespace of WebUI.Controllers as opposed to WebUI.Models (thus the type is IEnumerable<WebUI.Controllers.NavLink>. The error you are reporting certainly sounds like a namespace issue...

EDIT: One thing I found that helped me troubleshoot those examples was to download his source code and use a file comparison tool to compare his version to mine when I ran into a problem that I just couldn't figure out.

Mayo
Hi Mayo, In the second edition of the book Anderson has moved the NavLink to the Model so the namespace I have is correct. Thanks for the source code tip, I wasn't aware that is available to download. I will download and check out the differences. Thanks for the help.
fedor333