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 8592425
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:44:52+00:00 2026-06-11T23:44:52+00:00

What happens during a controller method call? Does MVC for every PUBLIC method in

  • 0

What happens during a controller method call? Does MVC for every PUBLIC method in your controller evaluate/set ModelState? Does it test EVERY class in the method parameters??

public ActionResult Create(Entity myEntity, AnotherEntity, myEntity2)
{
    if (ModelState.IsValid)
    {

If I had a return of int versus ActionResult:

public int Create(Entity myEntity, AnotherEntity, myEntity2)
{
    if (ModelState.IsValid)
    {

Would there still be a ModelState with the evaluated classes??

  • 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-11T23:44:53+00:00Added an answer on June 11, 2026 at 11:44 pm

    Actually it’s not the controller. It’s the model binder. The responsibility of the model binder is to instantiate the corresponding model given the request values. So the first step is model binding and the second step is validation. The first step is done by the model binder. If there’s an error during this step (for example you have attempted to bind an integer field on your model to an input text in which the user entered some arbitrary text), the model binder automatically adds an error to the model state, so once you enter the controller action you could test whether the ModelState.IsValid.

    If model binding succeeds then you have an instance of the model that is now passed to the corresponding validation framework. So for example if you are using Data Annotations and decorated the model properties with validation attributes, they will be evaluated and once again if there are errors they will automatically be added to the ModelState.

    If I had a return of int versus ActionResult:

    You would violate standard conventions in ASP.NET MVC where all controller actions must return ActionResult. But the return type really has nothing to do with model binding of input parameters and validation. The return type could be any of the possible derived classes of ActionResult or a custom one.

    So for example if you want to render the HTML representation of your model you return a ViewResult. If you want to return the JSON representation of your model you return a JsonResult. If you want to return some static string you return a ContentResult. If you want to allow the user download a file you return a FileResult. And so on.

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

Sidebar

Related Questions

This error happens during just about any rake task: project/Gemfile:4:in `evaluate': undefined method `ruby'
I am currently inserting a dependency in my mvc controller as shown below: public
I hope this is programming-related enough. What exactly happens during the shutdown process of
What happens in mysql multiple records insert during an error. I have a table:
What happens in the following code? Does the synchronization work? This is an interview
What happens when an application pool is recycled in IIS 7? Does IIS abruptly
This happens almost every time I init a new repo. Start a new project.
I have a TableView controller class that uses a fetched results controller to display
On some occasions, not every time, when my app presents a modal view controller
I am trying to understand what happens during race conditions on the Google AppEngine

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.