0

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

3 Answers 3

0

I'm working through Sanderson's book and had the same problem. The solution is that the file is named NavLink.cs while the menu inherits from NavLinks. Correct the link or rename the file and everything works.

Interesting problem that begs one question: How did you determine from the error message that this was a namespace issue? Earl B.

Sign up to request clarification or add additional context in comments.

1 Comment

Hi Earl - I didn't really know for sure to be honest , I more assumed that there was an issue with the inheritance/namespaces as there was no IntelliSense available in the model.
0

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.

1 Comment

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.
0

I have also found the the original idea of putting the classes into one file NavController.cs also creates this error.

Separate the classes into 3 files NavController.cs NavLink.cs CategoryLink.cs

All with the same Namespace namespace WebUI.Controllers

and it should solve the issue

Comments

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.