Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP.NET 4 > BOOK: Professional ASP.NET MVC 3
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 3
This is the forum to discuss the Wrox book Professional ASP.NET MVC 3 by Jon Galloway, Phil Haack, Brad Wilson, K. Scott Allen; ISBN: 978-1-1180-7658-3
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 3 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 16th, 2012, 06:13 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jul 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Confusing to follow code in Chapter 3 (Views)

Hi,
I'm finding it quite difficult to follow the code samples in Chapter 3 (Views).

I can see that NuGet has installed a Samples folder, but the samples dont work.

When I run http://localhost:6715/Albums/ListStronglyTyped, I get:

The model item passed into the dictionary is of type 'System.Collections.Generic.List`1[MvcMusicStore.Controllers.Album]', but this dictionary requires a model item of type 'System.Collections.Generic.IEnumerable`1[MvcMusicStore.Models.Album]'.


When I run http://localhost:6715/Albums/ListWeaklyTyped
I get errors on Line 4 below:

Object reference not set to an instance of an object.

Line 2:
Line 3: <ul>
Line 4: @foreach(Album p in (ViewBag.Albums as IEnumerable<Album>)) {
Line 5: <li>@p.Title</li>
Line 6: }

Help !!!

Last edited by gjok; July 16th, 2012 at 06:38 AM.
  #2 (permalink)  
Old February 21st, 2013, 08:51 AM
Registered User
Points: 3, Level: 1
Points: 3, Level: 1 Points: 3, Level: 1 Points: 3, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2013
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

You should use the following line on top of your View

Code:
@model IEnumerable<YourApp.Models.Albums>

Last edited by karthikreddy509; February 21st, 2013 at 08:59 AM.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 3 - Dynamic Views teamstar BOOK: Beginning iOS 5 Application Development 2 March 11th, 2012 12:12 PM
Confusing XPath chapter!!! skystar3 BOOK: Beginning XML, 4th Ed ISBN: 978-0-470-11487-2 2 December 8th, 2010 08:29 PM
Chapter 2 Unable to follow instructions GarethHowell BOOK: Professional SharePoint 2007 Development ISBN: 978-0-470-11756-9 4 July 9th, 2008 04:49 AM
Chapter 4 - Two Views, not working for me... bigtalk BOOK: Beginning Ruby on Rails 1 January 3rd, 2008 07:30 AM
deployment chapter hard to follow robert BOOK: ASP.NET Website Programming Problem-Design-Solution 3 June 20th, 2003 01:22 PM



All times are GMT -4. The time now is 12:37 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.