---
title: "can't pass formCollection to create method in asp.net mvc"  
description: "can't pass formCollection to create method in asp.net mvc"  
author: "Anonymous User"  
published: 2014-12-08  
updated: 2014-12-08  
canonical: https://www.mindstick.com/forum/12764/can-t-pass-formcollection-to-create-method-in-asp-dot-net-mvc  
category: "asp.net"  
tags: ["c#", "asp.net mvc"]  
reading_time: 3 minutes  

---

# can't pass formCollection to create method in asp.net mvc

I use [asp.net MVC](https://www.mindstick.com/forum/155798/what-is-caching-in-asp-dot-net-mvc) I and create a HTML Form not [razor](https://www.mindstick.com/articles/12002/asp-dot-net-mvc5-razor-with-jquery) I tried to used form [collection](https://www.mindstick.com/articles/1718/collections-in-java) to [pass data](https://www.mindstick.com/forum/351/how-to-pass-data-from-controller-to-ascx-page) from form to [View to controller](https://www.mindstick.com/forum/34314/post-data-from-view-to-controller-using-ajax) [public](https://www.mindstick.com/blog/11097/java-access-modifiers-the-public-and-the-private-modifiers) [ActionResult](https://www.mindstick.com/forum/33961/what-is-the-difference-between-actionresult-and-viewresult) Create(Address address) but no use can [someone help me](https://answers.mindstick.com/qa/42311/can-someone-help-me-with-this-question-about-political-parties) ?

**Address controller**

```
  public class AddressController : Controller    {        //        // GET: /Address/         public ActionResult Index()        {            return View();        }         //         // GET: /Address/Welcome/          public string Welcome()        {            return "This is the Welcome action method...";        }         [HttpPost]        public ActionResult Create(Address address)        {            //Loop through the request.forms             var Addesslist = new List<Address>();            for (int i = 0; i <= Request.Form.Count; i++)            {                var street = Request.Form["street_0" + i + ""];                var city = Request.Form["city_0" + i + ""];                var postalCode = Request.Form["postalCode_0" + i + ""];                var province = Request.Form["province_0" + i + ""];                var personID = 1;                if (street != null && city != null && postalCode != null && province != null)                {                    Addesslist.Add(new Address { Street = street, City = city, Province = province,PostalCode = postalCode,PersonID = personID});                }                else                {                    break;                }             }            return RedirectToAction("Index");            //Addesslist.ForEach(p => context.SaveChanges());            //if (context.SaveChanges() == Prod.Count)            //{            //    return RedirectToAction("Index");            //}            //else            //{            //    //Redirect to an error page or            //    return View(brand);            //}        }    }
```

## View

```
model PMX_MVC.Models.Address @{    ViewBag.Title = "Index";} <h2>Index</h2> @using (Html.BeginForm()) {    @Html.AntiForgeryToken()    @Html.ValidationSummary(true)         <div class="table-responsive">            <table id="address_table" class="table">                <thead>                    <tr>                        <th>Street</th>                        <th>City</th>                        <th>Province</th>                        <th>PostalCode</th>                        <th>&nbsp;</th>                     </tr>                </thead>                <tbody>                    <tr>                        <td>                            <input id="Text1" type="text" name="street_01" maxlength="255" required class="street" /></td>                        <td>                            <input id="Text2" type="text" name="city_01" maxlength="255" required class="city" /></td>                        <td>                            <input id="Text3" type="text" name="province_01" maxlength="255" required class="province" /></td>                        <td>                            <input id="Text4" type="text" name="postalCode_01" maxlength="7" required class="postalCode" /></td>                        <td>&nbsp;</td>                    </tr>                </tbody>            </table>        </div>        <input type="button" value="Add Row" id="add_AdressRow" class="btn btn-lg btn-success btn-block" />         <p>            <input type="submit" value="Create" />        </p> } <div>    @Html.ActionLink("Back to List", "Index")</div> @section Scripts {    @Scripts.Render("~/bundles/jqueryval")}
```

## Replies

### Reply by Barbara Jones

Any reasons why you are using Request.Form instead of the Address parameter in your action method?

Use of the Model Binder will be easier. You just have to name your input tags to match your Address model.

## Address model:

```
public class Address{   public string
Street {get;set;}   public string
Province {get;set;}   public string
PostalCode {get;set;}}
```

## View

```
<input id="Text1" type="text"name="Street" maxlength="255" required class="street"
/></td>
```

### Reply by Tom Cruser

Your actual issue is that this:

@using (Html.BeginForm())

..will post to a POST action method called Index. You need to specify the method you want to post to if this isn't what you want:

@using (Html.BeginForm("Create", "Address", FormMethod.Post))


---

Original Source: https://www.mindstick.com/forum/12764/can-t-pass-formcollection-to-create-method-in-asp-dot-net-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
