Which code segment should you use?

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.

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);}



Leave a Reply 4

Your email address will not be published. Required fields are marked *


erm

erm

It’s a POST so values are in the formcollection.

B and C are the correct in my opinion

z

z

I confirm : B and C.

With a POST method you can use FormCollection.

Request.QueryString work only with GET method.

Abdo

Abdo

That’s correct!

Roman

Roman

if form use formscollection values