Wrox Programmer Forums
BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950
This is the forum to discuss the Wrox book ASP.NET MVC Website Programming Problem Design Solution by Nicholas Berardi, Al Katawazi, and Marco Bellinaso; ISBN: 9780470410950
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old May 31st, 2010, 12:05 AM
nberardi's Avatar
Wrox Author
Join Date: Aug 2008
Posts: 102
Thanks: 1
Thanked 16 Times in 16 Posts
Send a message via AIM to nberardi

Originally Posted by fourpastmidnight View Post
Now, in version MVC 1.0, this "may" have been true (most certainly it was true for MVC 1.0 PR, which the book uses, I don't doubt that). However, in MVC 2.0, this is a new change. (maybe?) From what I've read, HttpPostAttribute only accepts HTTP POST verbs according to the changes FAQ on asp.net: http://www.asp.net/learn/whitepapers...t-mvc#_TOC3_12..
You should take a look at it again. It does only allow HTTP POST requests now, if defined. So in that case it is working fine.

The problem, that you are failing to realize, is that it doesn't follow HTTP standards, specifically around the HTTP 405 method not allowed.


Which is critical for some REST applications to function. Currently it returns an HTTP 404 Not Found response, which is totally wrong if they are trying to shoot for standards.


If you read 404 specs, it only applies to the URL, not the method used against the URL. The 405 response defines how the method should be responded to if not currently defined or allowed.

This has been my biggest problem with the MVC team, they sit back and talk about how standards compliment MVC is, and everybody is willing to just gobble it up, because they really want to believe it is true, and with out doing any research to make sure it is true. Don't worry you are not the only one who has made this mistake. And in the process of everybody talking about how standards compliment MVC is they are actually bastardizing the standard because none of them over their want to read or take the time to actually understand something as basic as HTTP status codes.

So if you want standards compliment code you still have to use my HttpPostOnly attribute, if you don't care, then use HttpPost.

As I stated before, we never mentioned ManagedFusion.dll in the whole book, because we totally expected it to be obsolete by publishing, but the MVC team has continued to let us down for a couple small features that makes your application that much more in line with standards. And me and Al weren't going to compromise on putting out crap, just because the MVC team doesn't understand the difference between a 404 and a 405.
Check out my blog at: http://www.coderjournal.com
Old May 31st, 2010, 09:13 AM
Registered User
Join Date: May 2010
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via AIM to fourpastmidnight Send a message via MSN to fourpastmidnight Send a message via Yahoo to fourpastmidnight
Thumbs up HTTP Post Only Actions


Wow! Thanks for the reply. Apparently, there is much more to this than just making sure you accept only HTTP POST verbs. I'm relatively "new" to Web programming. I understand the basics (which is probably what 80% of all "web programmers" really understand, if you think about it). I had no idea that the 404 would be returned through MS's attribute.

I am aware of most of the HTTP error codes, but 405 is not one of them. That's interesting. Thanks again, I am truly here to learn. Guess I should get my hands on the HTTP spec and check MS's code for what they're doing. It's unfortunate that I can't trust them to create "compliant" code when that's what they're touting.

Guess I'll be hooking back up ManagedFusion.Web.Mvc.dll.
Old June 14th, 2010, 01:53 PM
Registered User
Join Date: May 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default error in HTML.IF

I want to use membership part in another project. When I followed this chapter in TheBeerHouse project I did not face but in this new project I am facing. Could somebody please help?

I created Register method inside UserController. Then without doing other Logi, ManageUsers etc methods I continued with Register View. When I run application I am getting following error:

Compiler Error Message: CS1061:
'System.Web.Mvc.HtmlHelper<object>' does not contain a definition for 'If' and no extension method 'If' accepting a first argument of type 'System.Web.Mvc.HtmlHelper<object>' could be found (are you missing a using directive or an assembly reference?)


Line 13: <form method = "post" action = "<%= Url.Action("Register", "User") %>"
Line 14: <input type="hidden" name="returnUrl" value="<%= Html.If(!String.IsNullOrEmpty(Request.QueryString["returnUrl"]), () => Request.QueryString["returnUrl"])
Line 15: .ElseIf(Request.UrlReferrer != null, () => Request.UrlReferrer.ToString())
Line 16: .Else(() => String.Empty) %>"/>

Please help.
Old June 16th, 2010, 09:05 PM
Registered User
Join Date: May 2010
Posts: 13
Thanks: 1
Thanked 0 Times in 0 Posts
Send a message via AIM to fourpastmidnight Send a message via MSN to fourpastmidnight Send a message via Yahoo to fourpastmidnight
Cool HtmlHelper.If


The HtmlHelper.If method is not (to my knowledge) a standard .NET Base Class Library class. IIRC, this method is in one of the ManagedFusion.Web.*.dll files that came with the source code for the book (and which IIRC is freely downloadable and usable in your own projects). If it's not in ManagedFusion, it's in one of the other 3rd Party libraries.

I hope from what I've posted you can find this method.

Even if you can't, you don't need it. That method is just a nice way of doing If/Else constructs without all the "Classic ASP"-looking spaghetti code; but don't get me wrong, in the context of ASP.NET MVC, there's nothing wrong with the following code:

<% if (/* my boolean expression condition */ ) { %>
  <!-- Put some other ASP.NET code and/or HTML here. -->
<% } else { %>
  <!-- Do something else. -->
<% } %>
Old February 19th, 2011, 10:40 PM
Registered User
Join Date: Feb 2011
Posts: 7
Thanks: 1
Thanked 0 Times in 0 Posts

Next, right-click the project and, IIRC, there is' an Edit Project item. In any event, it will open up the XML file that resembles your project. Locate the following XML:
What is IIRC?

Still not clear about how to fix this, I've got the same Iso3166CountryCodes problem over "Properties" (does not exist in current context)

string[] iso3166 = Properties.Resources.Iso3166CountryCodes.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);

Am I missing something? Any feedback is appreciated, thank you.

Last edited by M3rcuryKT; February 20th, 2011 at 12:01 AM..

Similar Threads
Thread Thread Starter Forum Replies Last Post
Chapter 7 Object reference error in master.cs mikeal_a BOOK: Beginning ASP.NET 3.5 : in C# and VB BOOK ISBN: 978-0-470-18759-3 4 September 5th, 2008 07:19 AM
Chapter 4 pp. 118-119 luciano991 BOOK: Beginning PHP5, Apache, and MySQL Web Development ISBN: 978-0-7645-7966-0 1 August 13th, 2006 01:56 PM
Chapter 5 P 129 jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 1 June 16th, 2004 02:46 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.