Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8429807
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:26:20+00:00 2026-06-10T05:26:20+00:00

Obviously real life applications are a lot more complex but for this example sake

  • 0

Obviously real life applications are a lot more complex but for this example sake lets say I have the following simple view and I need to save the User:

@model UserViewModel


@Html.TextBoxFor(model=>model.FirstName)
</br>
@Html.TextBoxFor(model=>model.MiddleName)
</br>
@Html.TextBoxFor(model=>model.LastName)

When submitted there are two ways how I can receive it at the Controller level:

1)

public ActionResult(UserViewModel user)
{
 var myUser = new User();
 myUser = user.FirstName;
 myUser = user.MiddleName;
 myUser = user.LastName;
}

and

2)

public ActionResult(FormCollection collection)
{
 var myUser = new User();
 myUser = collection.Get("FirstName");
 myUser = collection.Get("MiddleName");
 myUser = collection.Get("LastName");
}

Question: Is there a reason to use one method over another ? Also a few developers told me that second method is preferred. That passing object the whole object like shown in the first example is not a good idea. Why ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:26:22+00:00Added an answer on June 10, 2026 at 5:26 am

    Short answer: both are working and both are valid.

    Long opinionated answer: I do prefer the first one,

    1. its more object oriented than the second one.
    2. you implicitly have magic strings in second approach. Of course you can externalize them etc, but again, strong types are always better than going string by string.
    3. you define your validations once in option 1, you have to do it over and over again in option 2.
    4. you can use AutoMapper. It will map most of fields with similar names for you and ask you to define the rest. Here you don’t have to move field by field at all (see below). You must however do it one by one in the second approach.
      It will look like this when you done with mappings (which is also trivial to do):

      public ActionResult(UserViewModel user)
      {
         var myUser = Mapper.Map<User, UserViewModel>(user);
      }
      

    Isn’t it a beauty?

    I don’t really see any reason why would option 2 be preferred over 1…
    I guess they have their reasons. Its like COBOL vs. C++. :))

    But this is really individual decision and style. There’s no right answer.

    Hope this is of help.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Real Dumb question. I figured I would have gotten this straight by now, but
I have this concrete problem, but if You find my initial design idea crazy
I have a WordPress site and the following link is accessible: www.domain.com/wp-admin/ (obviously not
I have found several similar answers but I can't quite get why this is
There might be an easy answer to this, but I can't for the life
Obviously best-case is O(n), but apparently the worst-case is O(n 2 ), which I
Obviously it's early days, I do not know whether this is information that is
Obviously I'd like to not have to install an Oracle client (other than simply
Obviously, sets do not have any kind of ordering, so I cannot expect any
So obviously I am doing something wrong, but I just cannot seem to get

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.