Asp.net mvc 3 HttpPost不在MVC3中工作

Asp.net mvc 3 HttpPost不在MVC3中工作,asp.net-mvc-3,Asp.net Mvc 3,当我在控制器中使用以下代码时 [HttpPost] public ActionResult Index(HttpPostedFileBase file) { string path = Path.Combine(Server.MapPath("~/Images"), Path.GetFileName(file.FileName)); file.SaveAs(path); ViewBag.Message =

当我在控制器中使用以下代码时

[HttpPost]
public ActionResult Index(HttpPostedFileBase file)
{
    string path = Path.Combine(Server.MapPath("~/Images"), 
                               Path.GetFileName(file.FileName));
    file.SaveAs(path);

    ViewBag.Message = "File Uploaded Successfully";

    return View();
}
当我运行应用程序时,我得到了以下错误

---Server Error in '/' Application.
---The resource cannot be found. 
当我删除
[HttpPost]
时,它会加载但不会上载文件


有人能帮我吗?……请确保您正在创建如下表单

@using (Html.BeginForm("Index", "Home", 
        FormMethod.Post,                
        new { enctype = "multipart/form-data" }))
{
    <input type="file" name="file" />
    <input type="submit" value="OK" />
}
@使用(Html.BeginForm(“索引”,“主页”,
FormMethod.Post,
新的{enctype=“multipart/form data”})
{
}

您能否使用用于从视图中调用操作的代码/表单更新您的问题?控制器中是否有另一个
Index
方法具有属性
[HttpGet]