加入收藏 | 设为首页 | 会员中心 | 我要投稿 商洛站长网 (https://www.0914zz.com/)- AI应用、CDN、边缘计算、云计算、物联网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc C 已经使用相同的参数类型定义了一个名为“Create”的成员

发布时间:2023-12-16 12:52:21 所属栏目:asp.Net 来源:DaWei
导读: 这个问题在这里已经有一个答案:>
GET and POST methods with the same Action name in the same Controller7个

我有两种方法和不同的http动词:


public class ProductImageC

这个问题在这里已经有一个答案:> GET and POST methods with the same Action name in the same Controller7个
我有两种方法和不同的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 } }

(编辑:商洛站长网)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章