MVC - Multiple forms on same page using same controller action

  • Thread starter Thread starter Mike Gleason jr Couturier
  • Start date Start date
M

Mike Gleason jr Couturier

(.NET MVC RC1)

Hi,

I have a login form in my master view. A user can login with that form from
every View (and the system stays on that view after a successful login or
not)

So let's say we have a contact-us page like this:

<!-- ---- Generated by the master view -------- -->
<form action="/About/Contact">
<<login form here>>
</form>

<!-- ---- Generated by the view using the master -------- -->
<form action="/About/Contact">
<<contact us form here>>
</form>

In the About controller, how can I differenciate a "login post" from a
"contact us post"?
Is there any [filter] for this to separated the two POSTs?
Is the only solution is to create a hidden field "Login=true" in the login
form?

(PS. Forget about the code duplication this architecture can bring)

Thanks! Mike
 
mvc doesn't hide the fact that a form post is just a namevalue
collection, with a postback (action) url. if there are two forms on a
page, only data from the posting form is sent by the browser

if two forms post to the same controller and the controller needs to
distinguish which form is the source (not sure why you would do this),
then you need to pass a form value that can be used.

normally you would have the login form would post to a login controller.

-- bruce (sqlwork.com)
 
Back
Top