Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9
This is the forum to discuss the Wrox book Professional ASP.NET MVC 1.0 by Rob Conery, Scott Hanselman, Phil Haack, Scott Guthrie; ISBN: 978-0-470-38461-9
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 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 Search this Thread Display Modes
  #1 (permalink)  
Old April 1st, 2009, 04:53 PM
Friend of Wrox
Points: 546, Level: 8
Points: 546, Level: 8 Points: 546, Level: 8 Points: 546, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Location: Portland, OR
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
Default Chapter 1 - NerdDinner - Errors

The pdf version of chapter one is great, thanks. However I did find an error in the code. On pdf page 105 (book 103) the ActionResults Edit shows an attribute of [Authorize]. This should be left out of the code until later (pdf page 126) when authorization is discussed. Including it will produce a challenge response for using the edit page with the newly added country drop down.
  #2 (permalink)  
Old April 3rd, 2009, 06:38 PM
Friend of Wrox
Points: 546, Level: 8
Points: 546, Level: 8 Points: 546, Level: 8 Points: 546, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Location: Portland, OR
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
Default

on page 105 of the PDF the instructions state:
We’ll then update our view template so that it expects a “DinnerFormViewModel” instead of a “Dinner”
object by changing the “inherits” attribute at the top of the edit.aspx page like so:
Inherits="System.Web.Mvc.ViewPage<NerdDinner.Contr ollers.DinnerFormViewModel>

The inherits statement needs to also be included in the create.aspx. The follwing pages address making the required changes to the ActionResult methods for both the edit and ceate, but the inherit for the create.aspx is not mentioned. This generates an error otherwise.
  #3 (permalink)  
Old April 3rd, 2009, 06:48 PM
Friend of Wrox
Points: 546, Level: 8
Points: 546, Level: 8 Points: 546, Level: 8 Points: 546, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Location: Portland, OR
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
Default

page 116 of the pdf:

All of the view templates we’ve created for our NerdDinner application (“List”, “Details”, “Edit”,
“Create”, “NotFound”, etc) have been based on this Site.master template. This is indicated via the
“MasterPageFile” attribute that was added by default to the top <% @ Page %> directive when we
created our views using the “Add View” dialog:

Code:
<%@ Page Language="C#"
Inherits="System.Web.Mvc.ViewPage<NerdDinner.Controllers.DinnerViewModel>"
MasterPageFile="~/Views/Shared/Site.Master" %>
There is no "List" View (probably means Index) and only the "Edit" And "Create" use the <NerdDinner.Controllers.DinnerViewModel> the "Details" uses <NerdDinner.Models.Dinner> and the "Not Found" uses 'none of the above'

They do all use the same master page, which is the point being made, but implying that all use the same <% @ page %> is a erroneous.

Last edited by Steve S; April 3rd, 2009 at 06:53 PM..
  #4 (permalink)  
Old April 3rd, 2009, 08:00 PM
Friend of Wrox
Points: 546, Level: 8
Points: 546, Level: 8 Points: 546, Level: 8 Points: 546, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Location: Portland, OR
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
Default

bottom of page 125:

We can then update the \Views\Dinners\Index.aspx view template to inherit from ViewPage <NerdDinner.Helpers.PaginatedList<Dinner>> instead of ViewPage<IEnumerable<Dinner>>,
and then add the following code to the bottom of our view-template to show or hide next and previous
navigation UI:

This should really be
<NerdDinner.Helpers.PaginatedList<NerdDinner.Models.Dinner>> per the sample code.
The Following User Says Thank You to Steve S For This Useful Post:
  #5 (permalink)  
Old April 9th, 2009, 01:14 PM
Friend of Wrox
Points: 546, Level: 8
Points: 546, Level: 8 Points: 546, Level: 8 Points: 546, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Location: Portland, OR
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
Default

The first 100 - ~130 pages are pretty good with good accuracy, but after that things start getting dicey.

I've been going back and forth with the AJAX map on pages 146 - 155 following step by step. No errors, but no map either. I've tested the sample code and it works as outlined, but following the first chapter pdf doesn't. So far I can not see what is preventing the code from working and have tried easter egging the download code with the sample code and still have not gotten the map to show up.

Beyond page 144 Scott starts introducing named div tags in the code with no mention of them or the CSS, which is also much different in the download code than comes with a new project creation; which is to be expected, but it would have been nice if it weren't foregotten.

Yes, I could just use the download code, but the knowledge transfer ins't as great as the hands on step-by-step approach that the first chapter is supposed to be.

I would expect Wrox and the Gu are going to field lots of traffic on the last 50 pages of chapter one.

My Bad. On Page 145 is this snippet
<script src="/Scripts/jQuery-1.3.2.js" type="text/javascript"></script>
I grabbed this one from the working download sample
<script src="/Scripts/jquery-1.2.6.js" type="text/javascript"></script>

Little bit of a versioning issue there. Now the maps are showing, but in the wrong size and location

Last edited by Steve S; April 9th, 2009 at 02:25 PM..
  #6 (permalink)  
Old April 10th, 2009, 03:33 PM
Friend of Wrox
Points: 546, Level: 8
Points: 546, Level: 8 Points: 546, Level: 8 Points: 546, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Location: Portland, OR
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
Default

I am growing more than a little frustrated in Scott Gu's walk through tutorial. The further into it I get it is obvious that there was little attention to detail towards the end on Scott's part and even less by any technical editor.

On page 181 is:
Code:
[TestMethod]
public void EditAction_Should_Return_View_For_ValidDinner() {
// Arrange
var controller = CreateDinnersController();
// Act
var result = controller.Edit(1) as ViewResult;
// Assert
Assert.IsInstanceOfType(result.ViewData.Model,
typeof(DinnerFormViewModel));
}
As Pointed out this test fails for lack of User Identity, so far so good. To address this the subject of mocking is brought up, along with a URL to download Moq, which I did (version 3.0.802)

At the top of page 183 a new DinnersController is created using the new mocking:
Code:
DinnersController CreateDinnersControllerAs(string userName) {
var mock = new Mock<ControllerContext>();
mock.SetupGet(p => p.HttpContext.User.Identity.Name).Returns(userName);
mock.SetupGet(p => p.HttpContext.Request.IsAuthenticated).Returns(true);
var controller = CreateDinnersController();
controller.ControllerContext = mock.Object;
return controller;
}
On Page 183 two more tests are added:
Code:
[TestMethod]
public void EditAction_Should_Return_EditView_When_ValidOwner() {
// Arrange
var controller = CreateControllerAs("SomeUser");
// Act
var result = controller.Edit(1) as ViewResult;
// Assert
Assert.IsInstanceOfType(result.ViewData.Model,
typeof(DinnerFormViewModel));
}
[TestMethod]
public void EditAction_Should_Return_InvalidOwnerView_When_InvalidOwner() {
// Arrange
var controller = CreateControllerAs("NotOwnerUser");
// Act
var result = controller.Edit(1) as ViewResult;
// Assert
Assert.AreEqual(result.ViewName, "InvalidOwner");
}
As shown higlighted in Red the tests call a non existent create routine. Also There seems to be a disconnect between the download code and the PDF chapter. EditAction_Should_Return_EditView_When_ValidOwner( ) is in the book but not in the download code. The download code has EditAction_Should_Return_View_For_ValidDinner(), which is modfied to address the user shown in the first code section above from page 181.

And, to top it off the tests are now not being executed because the downloaded moq.dll is not trusted. Arrrrrgghhh

Last edited by Steve S; April 10th, 2009 at 03:35 PM..
  #7 (permalink)  
Old April 10th, 2009, 04:57 PM
Friend of Wrox
Points: 546, Level: 8
Points: 546, Level: 8 Points: 546, Level: 8 Points: 546, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2009
Location: Portland, OR
Posts: 105
Thanks: 3
Thanked 20 Times in 19 Posts
Default

On pdf page 83 the AddRuleViolations method is added to the Control Helpers class and is used/mentioned through page 100 several times. By the time the reader is at page 184 this method is no longer mentioned or used and a new method AddModelErrors is introduced in its stead.

I realize that over the course of a tutorial calls and items will be changed and improvements will be made; it would be helpfull to the user following the tutorial if these changes were a bit more explicit than just depracted with no mention. It would allow the student a higher success rate, less frustration and fewer inqueries to the author or publisher about them.

All in all a good tutorial but the last 60 pages could have used more attention to detail and better technical editing.
  #8 (permalink)  
Old May 7th, 2009, 07:01 PM
Registered User
 
Join Date: May 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default /Dinners/Create POST error

has anyone else run into this issue (our did I just not read carefully and miss a code change)

on page 89 (chapter 1) the DinnersController implements a Create (POST) method to create/persist a new Dinner object.

The code shown in the book is as follows:
Code:
//
// POST: /Dinners/Create
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Create(Dinner dinner) {
if (ModelState.IsValid) {
try {
dinner.HostedBy = "SomeUser";
dinnerRepository.Add(dinner);
dinnerRepository.Save();
return RedirectToAction("Details", new {id = dinner.DinnerID });
}
catch {
ModelState.AddRuleViolations(dinner.GetRuleViolations());
}
}
return View(dinner);
}
I don't see how this method is supposed to ever work properly for a few reasons:
  1. HostedBy has a validation rule (pg 39) that says it can't be null or empty. In this case it will always be null when IsValid is called because the property isn't set until the
    Code:
    if (ModelState.IsValid)
    condition is met.
  2. If the model is not valid the view is returned but a call to
    Code:
    ModelState.AddRuleViolations(dinner.GetRuleViolations());
    is never made so the actual rule violations are not added to the ModelState and consequently no error are displayed on the view.
Did I miss a step outlined in the chapter or is this an accurate assessment of this implementation?
  #9 (permalink)  
Old June 13th, 2009, 03:25 PM
Authorized User
 
Join Date: Jun 2009
Posts: 20
Thanks: 0
Thanked 1 Time in 1 Post
Default Small CSS Error

Style for hr element in the file: Site.css looks like this:

Code:
hr
{
    padding:0px, 10px, 0px, 10px;
    height:1px;
}
I know that it's really small detail, but the value should be without commas!

S.
  #10 (permalink)  
Old October 8th, 2009, 06:23 AM
Registered User
 
Join Date: Oct 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Dinner Controller Class

There seems to be an error in the errata of this book...

pg 71... They discuss the cleanliness of creating of extending the ModelState Dictionary by adding an AddRuleViolations method... this is all fair except that when you try to compile the code it wont build cos its fraught with errors. So is the errata of this book... it just make no sense.

Anyone experience issues with this?
 


Thread Tools Search this Thread
Search this Thread:

Advanced Search
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
NerdDinner The view 'Index' or its master could not be found rthorington BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 3 May 3rd, 2009 04:30 PM
NerdDinner.Tests Project Missing Stuff dwrogers BOOK: Professional ASP.NET MVC 1.0 ISBN: 978-0-470-38461-9 2 March 22nd, 2009 09:54 AM
More Errors in chapter 7..... rollercoaster BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 5 October 3rd, 2006 03:49 PM
Chapter 6 Try It Out errors Voltron ASP.NET 2.0 Basics 0 August 9th, 2006 01:42 AM
Chapter 4 Errors? DRAYKKO BOOK: Beginning Java 2 3 June 1st, 2004 07:47 AM



All times are GMT -4. The time now is 05:07 PM.


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