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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:13:46+00:00 2026-05-22T20:13:46+00:00

I have the following Action to display a form with 3 items : [HttpGet]

  • 0

I have the following Action to display a form with 3 items :

[HttpGet]
    public ActionResult ReferAFriend()
    {
        List<ReferAFriendModel> friends = new List<ReferAFriendModel>();
        ReferAFriendModel f1 = new ReferAFriendModel();
        ReferAFriendModel f2 = new ReferAFriendModel();
        ReferAFriendModel f3 = new ReferAFriendModel();

        friends.Add(f1);
        friends.Add(f2);
        friends.Add(f3);
        return View(friends);
    }

and then a Post action

[HttpPost]
    public ActionResult ReferAFriend(IEnumerable<ReferAFriendModel> friends)
    {
        if(ModelState.IsValid){

EDIT
My View looks like this:

@model IEnumerable<Models.ReferAFriendModel>
@for(int i=0;i<Model.Count();i++)
    {
        @Html.Partial("_ReferAFriend", Model.ElementAt(i));
    }

The partial looks like this:

@model Models.ReferAFriendModel
<p>
   @Html.LabelFor(i => i.FullName) @Html.TextBoxFor(i => i.FullName)<br />
   @Html.LabelFor(i => i.EmailAddress) @Html.TextBoxFor(i => i.EmailAddress)
   @Html.HiddenFor(i=>i.Id)
</p>

When I post, I can see the fields are posted in the Request.Form object e.g Request.Form[“FullName”] will show: “David Beckham”,”Thierry Henry”. “Chicharito Fergurson” which are the values I entered in the form. But, the in the Post action,the value for ‘friends’ is always null. The ReferAFriendModel has three public properties Id, EmailAddress and FullName.

What am I doing wrong?

  • 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-22T20:13:47+00:00Added an answer on May 22, 2026 at 8:13 pm

    You may take a look at the following blog post about the wire format for arrays and dictionaries. Personally I always use editor templates in my views which take care of generating proper names of the input fields so that the default model binder is able to bind the values correctly.

    @model IEnumerable<ReferAFriendModel>
    @using (Html.BEginForm())
    {
        @Html.EditorForModel()
        <input type="submit" value="OK" />
    }
    

    and in the corresponding editor template (~/Views/Shared/EditorTemplates/ReferAFriendModel.cshtml):

    @model ReferAFriendModel
    @Html.EditorFor(x => x.Prop1)
    @Html.EditorFor(x => x.Prop2)
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have the following form <form action=#!/search/ method=get style=display:inline; id=hdr_q> <table cellpadding=0 cellspacing=0> <tr><td><input
Hi, I have the following in my view : <form id=list_ad method=get class=adListFilter action=<%=Url.Action(List,
I have the following controller action and test. I'm new to testing with Shoulda
I have the following route defined routes.MapRoute( ItemName, {controller}/{action}/{projectName}/{name}, new { controller = Home,
I Have following code: Controller: public ActionResult Step1() { return View(); } [AcceptVerbs(HttpVerbs.Post)] public
I have the following button with associated context menu <div class=control-action> <button>Action</button> <ul style=display:none>
I have written the following contact form validation script. How can I validate a
I have found this example on StackOverflow: var people = new List<Person> { new
I have a namespace extension and when the user does certain action we display
I am trying to use the ViewBag to display the action for a form

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.