ASP.NET MVC3-收到“方法\'BeginForm\'的不重载需要6个参数”错误消息

问题描述

| 我的控制器有以下两种方法...
public FileResult GetImage(int id)
    {
     // something
    }
    public FileResult GetImageTwo(int id)
    {
     // something   
    }
Create.cshtml作为以下代码...
@using (Html.BeginForm(\"Create\",\"ProductCategory\",\"GetImage\",\"GetImageTwo\",FormMethod.Post,new { enctype = \"multipart/form-data\" 
}))
  更新资料 因此,答案是无法像这样完成。     

解决方法

您需要指定要发布到哪个控制器操作,并使用适当的重载:
                         action      controller            method                htmlAttributes
                            ↓             ↓                   ↓                        ↓
@using (Html.BeginForm(\"GetImage\",\"ProductCategory\",FormMethod.Post,new { enctype = \"multipart/form-data\" }))
{
    //somecode
}
    ,这与路线无关。错误很简单,您正在调用不存在的“ 3”重载。换句话说,没有像
Html.BeginForm
这样的方法需要6个参数。如果您更新问题以显示您要达到的目标,也许堆栈可以帮助您     

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...