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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T10:16:00+00:00 2026-06-18T10:16:00+00:00

My question is about binding in MVC. Could you please help me with it?

  • 0

My question is about binding in MVC. Could you please help me with it?

My controller:

public class TestController : Controller
 {
        //
        // GET: /Test/
        [HttpGet]
        public ActionResult Index()
        {
            return View(new TestModel());
        }
        public ActionResult Index(TestModel test)
        {
           return View(test);
        }
 }

My View:

@model MvcApplication1.Models.TestModel

@using (Html.BeginForm())
{
@Html.TextBoxFor(x => x.test) // or x.Test
<input type="submit" value="Set"/>
}

My model:

public class TestModel
{
public string test { get; set; } // or Test{get;set;}
}

The problem is connected with the name of parameter “test” in controller as I understand. I have just changed it to “model” and the binding is working. But it is not working in original state (the name of parameter is ‘test’), ‘test’ parameter is null.

Please give me understand why the binding is not working in current example. Thank you a lot!

  • 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-18T10:16:01+00:00Added an answer on June 18, 2026 at 10:16 am

    You need an [HttpPost] attribute on your second method. You also cannot use test as your variable name, as it is the same name as the property of the class you’re attempting to bind to; the ModelBinder fails to determine which to use. Your code would look as follows:

    public class TestController : Controller
     {
            //
            // GET: /Test/
            [HttpGet]
            public ActionResult Index()
            {
                return View(new TestModel());
            }
    
            //
            // POST: /Test/
            [HttpPost]
            public ActionResult Index(TestModel testModel)
            {
               return View(testModel);
            }
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a question about ASP.NET MVC3 model binding. If I have a class
I have a very basic question about binding between controls. I have a class
Question about subclassing in matlab, under the new class system. I've got class A
A question about inheritance in java... class Base { private int val = 10;
I am new to both Haskell and programming. My question about binding in pattern-matched,
I have a question about data binding in WP7 using c# code. If I
I have a question about Mvvmlight binding Listbox SelectedIndex. The full source code can
i have a quick Binding Question about Silverlight. I have some Expander and want
I've got a question about the binding of checkboxes. Is it possible to bind
1.i have 2 question about knockout on asp.net. server side method: <WebMethod> Public Shared

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.