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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:37:08+00:00 2026-05-27T00:37:08+00:00

For instance, there is some object that will be model for strongly-typed view: class

  • 0

For instance, there is some object that will be model for strongly-typed view:

class SomeModel {
    public string SomeUsualField { get; set; }
}

Further, some action exists in controller that will work with object specified above:

public ActionResult Index(SomeModel obj)
{ 
    return View(obj);
}

So the question is why obj isn’t a null while Index action first called? It’s created new instance of SomeModel class with null SomeUsualField.

  • 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-05-27T00:37:09+00:00Added an answer on May 27, 2026 at 12:37 am

    The ASP.NET MVC model binding infrastructure tries to fill all properties with data coming from the request object (query string, form fields, …). Therefore it creates an instance of all parameters of the controller to try to match the properties.
    Because you don’t pass a SomeUsualField, it is null, but the parameter object has an empty instance.

    You can initialize the property SomeUsualField when you call http://localhost/MySite/MyController/Index?SomeUsualField=test. The property SomeUsualField will automagically initialized with ‘test’

    If you don’t want the parameter to be set, you can leave it away and make a 2nd action with the attribute [HttpPost]. A good tutorial is the music store.

    public ActionResult Index() 
    {  
        var obj = new SomeModel();
        return View(obj); 
    } 
    
    [HttpPost]
    public ActionResult Index(SomeModel obj) 
    {  
        // update logic
        return View(obj); 
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way to transfer a new class instance (python class that inherits
So I have a view model that takes an instance of IAdapter right? And
I wanted to write some code like this: class SomeModel(models.Model): field = models.ForeignKey(SomeOtherModel) def
I use a foreach in my View to loop over my strongly-typed Model and
In ActionScript 3, there are some classes that will represent a value rather than
is there a way how to fully load some SQLAlchemy ORM mapped instance (together
Is there a way to start an instance of eclipse, passing it some sort
In my project there are some 'Prototype' factories that create instances by cloning a
Is there a way to create an instance of a class based on the
Will there normally only be one instance of MainForm? I need to hold it

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.