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

  • Home
  • SEARCH
  • 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 8480441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:17:44+00:00 2026-06-10T19:17:44+00:00

I´m still learning my way around MVC programming and have one question for you

  • 0

I´m still learning my way around MVC programming and have one question for you to clarify one thing for me regarding Get and POST ActionResult functions within my controllers. I´ll give you three possible scenarios (and actually three questions):

My first scenario:

public ActionResult Derp()
{
    Derpina derpina = new Derpina(); //Should I need to pass this to View?
    return View(derpina);
}

[HttpPost]
public ActionResult Derp()
{
    Derpina derpina = new Derpina();
    UpdateModel(derpina);
    //doStuff and save to DB
    return RedirectToAction("Index");
}

My second scenario:

public ActionResult Derp()
{
    return View();
}

[HttpPost]
public ActionResult Derp()
{
    Derpina derpina = new Derpina(); //Is this the cleanest way?
    UpdateModel(derpina);
    //doStuff and save to DB
    return RedirectToAction("Index");
}

My third scenario:

public ActionResult Derp()
{
    Derpina derpina = new Derpina();
    return View(derpina);
}

[HttpPost]
public ActionResult Derp(Derpina derpina)
{
    UpdateModel(derpina); //Should I need to do that at all?
    //doStuff and save to DB
    return RedirectToAction("Index");
}

I´m leaning toward the second scenario because I have no need to create new entity and pass it to the View. I guess that´s why I´m asking you guys, somebody told me once that there are no “stupid questions” so I hope you will bear with me 🙂

  1. Should I need to pass newly created Derpina to the View
  2. Isn´t the second scenario the “best practise”?
  3. In the third scenario, if I pass Derpina as parameter into the HttpPost function, has the MVC framework not already updated the model?

Englis is not my native language so I hope these questions make any sense. Anyway, thank you in advance for any help you can give me to clarify.

EDITED

After one answer I received I want to add the fourth scenario:

public ActionResult CreateDerp()
{
    return View();
}

[HttpPost]
public ActionResult CreateDerp(Derpina derpina)
{
    UpdateModel(derpina);
    //doStuff and save to DB
    return RedirectToAction("Index");
}

Would that be the right approach, I mean if I´m not needed to send model to the View in the GET function? For instance if I were using Create functions like the above code suggests.

  • 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-10T19:17:46+00:00Added an answer on June 10, 2026 at 7:17 pm

    1st question -> If you have a view that must display data from your database, you need to send a model to the view so it can display the desired data on your page.

    2nd question -> At post it is always recomended if not needed to get your model as a parameter in the post method, that`s the entire purpose of the model binder, how you update your data in the database should be separated in a bussines layer of your application, thats the cleanest way, in my opinion.

    3rd question -> The mvc framework indeed created a new model containing the data from your view (if the user entered any), however, that does not mean it will update your object automatically or apply the changes in your database, you must do that explicitly, the way you require it.

    I hope i’ve been at least a bit helpful.

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

Sidebar

Related Questions

Sure this is a simple one - still learning my way around sh scripts.
I'm still learning Ruby and I have a question concerning hash of hashes. The
Ihaven't done much MVC and still learning the hard way on how to do
I'm still learning my way around jQuery but I think this may be pretty
Sorry still learning Yii so newbie question. I have a site im converting over
Still learning magento coding. I wonder is there a way I can print out
Still learning WPF....thanks for any help. Is there any way to Refactor this: <ListBox
Still learning JSP Web Applications here. I have been doing this for a while
I'm still learning Python as great simple programming language, the problem came with DataBase
Still fooling around with WPF and learning as I go. Trying now to build

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.