p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   BOOK: ASP.NET MVC Website Programming Problem Design Solution ISBN: 9780470410950 (http://p2p.wrox.com/forumdisplay.php?f=472)
-   -   Action Method to handle POST, ex. ManageUser (http://p2p.wrox.com/showthread.php?t=75393)

philthy July 25th, 2009 06:44 AM

Action Method to handle POST, ex. ManageUser
 
There is one version of the ManageUser action with the
"[Authorize(Roles = "Admin")]" attribute on it. In the ManageUser View, there is a <form method="post" action="ManageUser">

The way I understand it, there should be a ManageUser action with an
[AcceptVerbs("POST")] attribute, to handle what is posted by the user, right?

How come it is possible to do it in this way, when other Action methods has an overloaded version to handle POST?

I don't see the difference...

philthy September 8th, 2009 03:14 AM

Does anyone have an answer to this?

oldcode September 14th, 2009 04:57 PM

A Post [AcceptVerbs] attribute isn't a requirement for an action to fire for a post. You only need a so-called "post overload" if you have two action methods with the same name, one for the get, which serves up a form, and one for the post of the form. A quote from ScotGu's blog:
http://weblogs.asp.net/scottgu/archi...sed.aspx#seven
"By default ASP.NET MVC now looks for an action method that explicitly supports the incoming http verb - and if one is not found will use the action method that doesn't have an explicit verb specified."

There's only one ManageUser action, and it fires for both get and posts.


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

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