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

这个问题在这里已经有一个答案:> 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
    }
}

相关文章

### 创建一个gRPC服务项目(grpc服务端)和一个 webapi项目(...
一、SiganlR 使用的协议类型 1.websocket即时通讯协议 2.Ser...
.Net 6 WebApi 项目 在Linux系统上 打包成Docker镜像,发布为...
一、 PD简介PowerDesigner 是一个集所有现代建模技术于一身的...
一、存储过程 存储过程就像数据库中运行的方法(函数) 优点:...
一、Ueditor的下载 1、百度编辑器下载地址:http://ueditor....