already defines a member called 'Create' with the same parameter types

Mohammadreza picture Mohammadreza · Nov 18, 2013 · Viewed 15k times · Source

I Have two method and distinct by http verb:

public class ProductImageController : Controller
{
     [HttpGet]
     public ViewResult Create(int productId)
          {
             return View(productId);
          }

      [HttpPost]
      public ViewResult Create(int productId)
          {
          }
}

but Get Error:

already defines a member called 'Create' with the same parameter types

Answer

Chris L picture Chris L · Nov 18, 2013

You can't have multiple methods with the same signature within the same scope like that i.e. same return type and parameter type.

EDIT- Looks like you need to use this: Related question

public class ProductImageController : Controller
{
     [HttpGet]
     public ViewResult Create(int productId)
     {
         return View(productId);
     }

    [HttpPost]
    [ActionName("Create")]
    public ViewResult CreatePost(int productId)
    {
        //return a View() somewhere in here
    }
}