I have a form on my view with 2 fields. The user clicks on the submit button and some data will be queried specific to that user and the data they entered into the form.
The user’s email address is passed on the URL. (e.g. ActionName?user_email=yaddd@yyy.com)
I need to collect the form data and the email from the URL and pass it into my controller.
I need the data to query from my database and display a message to the user.
I can’t find any good links or sites regarding this issue.
This is what I have tried so far:
[HttpPost]
public ActionResult Collect(String s1, String s2, string user_email)
{}
and
[HttpPost]
public ActionResult Collect(FormCollection fm, string user_email)
{}
They don’t seem to collect the form data at all. What do you suggest?
Have you considered using model binding? Ideally, I would use model binding for the data you are sending in the form and use parameters on action for the querystrings. So in your case I would define a model like below
And then define the action as
This has always worked for me. Give it a try and let me know if it does not work