相关疑难解决方法(0)

在Html.BeginForm MVC4控制器动作中传递多个参数

我有这样的事情:

   public ActionResult ImageReplace(int imgid,HttpPostedFileBase file)
    {
        string keyword = imgid.ToString();
        .......
    }
Run Code Online (Sandbox Code Playgroud)

在我的.cshtml中:

   @model Models.MemberData
   @using (Html.BeginForm("ImageReplace", "Member", FormMethod.Post,
            new { imgid = @Model.Id, enctype = "multipart/form-data" }))
        { 
     <input type="file" name="file" id="file" value="Choose Photo"  /> 
     <input type="submit" name="submit" value="Submit" />
    }
Run Code Online (Sandbox Code Playgroud)

这里imgid的值没有传递给控制器​​动作.显示错误,参数字典包含参数'imgid'的非可空类型'System.Int32'的空条目,用于方法'System.Web.Mvc.ActionResult ImageReplace

c# asp.net-mvc asp.net-mvc-4

5
推荐指数
1
解决办法
6万
查看次数

标签 统计

asp.net-mvc ×1

asp.net-mvc-4 ×1

c# ×1