You are developing an ASP.NET MVC application.
The application has a contact view includes a form for editing the displayed contact.
You need to save the Contact object model when the form is posted back to the EditContact method using a
POST method request.
Which code segment should you use? Each correct answer presents a complete solution. Choose all that
apply.
A.
public ActionResult EditContact(){var c = newContact(){FirstName = Request.QueryString
[‘”FirstName”‘],LastName = Request.QueryString[“LastName”]},SaveContact(c);return View(c);}
B.
public ActionResult EditContact(Contact c){SaveContact(c);return View(c);}
C.
public ActionResult EditContact(FormCollection values){var c = newContact(){FirstName = values[‘”FirstName”‘],LastName = values[“LastName”]},SaveContact(c);return View(c);}
D.
public ActionResult EditContact(QueryStringProvider values){var c = newContact(){FirstName =
values.GetValue[‘”FirstName”‘],LastName = values.GetValue [“LastName”]},SaveContact(c);return View(c);}
It’s a POST so values are in the formcollection.
B and C are the correct in my opinion
I confirm : B and C.
With a POST method you can use FormCollection.
Request.QueryString work only with GET method.
That’s correct!
if form use formscollection values