这个问题在这里已经有一个答案:>
GET and POST methods with the same Action name in the same Controller7个
我有两种方法和不同的http动词:
我有两种方法和不同的http动词:
public class ProductImageController : Controller { [HttpGet] public ViewResult Create(int productId) { return View(productId); } [HttpPost] public ViewResult Create(int productId) { } }
但获取错误:
already defines a member called ‘Create’ with the same parameter types
解决方法
您不能在同一范围内具有相同签名的多个方法,例如相同的返回类型和参数类型.
编辑-
看起来你需要使用这个: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 } }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。