MVC - Multiple forms on same page using same controller action

  • Thread starter Mike Gleason jr Couturier
  • 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
 
B

bruce barker

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top