When i add 2 Create Method in my controller like below
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Create()
{
Product.Models.Product p = new Models.Product();
//update DB
try
{
return RedirectToAction("GetAll");
}
catch (Exception)
{
return View(p);
}
}
//
// POST: /Product/Default1/Create
[AcceptVerbs(HttpVerbs.Posr)]
public ActionResult Create(FormCollection collection)
{
try
{
if (myProduct.Products == null)
{
myProduct.Products = new List<Models.Product>();
}
Product.Models.Product p = new Product.Models.Product();
p.Name = collection["Name"];
p.ProductType = collection["ProductType"];
p.Id = myProduct.Products.Count + 1;
myProduct.Products.Add(p);
return RedirectToAction("Index");
}
catch
{
return View();
}
}
If i Comment GET action verbs and run application, application throws error resource not found. It will not fire Create Action. my html has @using (Html.BeginForm())
I Changed Form to even then i get same error. If i uncomment GET action verb, then always GET method fires up. I want call POST Create action . Can any1 directme how to solve.
I have Product has Areas in my MVC project. within in it has ProductsController.cs Please help me how to call POST action Create method.
-Mahender