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
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
}
}
Change the post action method like below:
[HttpPost]
public ViewResult Create(FormCollection formValues)
{
var productId = formValues["productId"];
}
OR
[HttpPost]
public ViewResult Create(int productId, FormCollection formValues)
{
//still using productId, formValues is just an additional parameter
//that doesn't need to be implemented.
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With