MVC +表单:发布错误

时间:2015-06-03 19:43:02

标签: asp.net asp.net-mvc asp.net-mvc-4 asp.net-mvc-5 iis-express

每当我尝试在我的MVC网站上做一个简单的表单发布时,我都会收到以下错误。

  

在HttpRequest.GetBufferedInputStream的调用者填充内部存储之前,访问了BinaryRead,Form,Files或InputStream。

     

描述:执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

     

异常详细信息:System.InvalidOperationException:在HttpRequest.GetBufferedInputStream的调用者填充内部存储之前,访问了BinaryRead,Form,Files或InputStream。

enter image description here

我的示例表单和操作非常基本......

@using (Html.BeginForm("Create", "Form"))
{
    <div class="row action">
        <div class="row">
            First name: <input type="text" name="fname"><br>
            Last name: <input type="text" name="lname"><br>
        </div>
        <input type="submit" id="save" class="btn" value="Save"/>
        <input type="button" id="cancel" class="btn" value="Cancel"/>
     </div>
}

我的控制器动作更基本......

[HttpPost]
    public ActionResult Create(FormCollection collection)
    {
        try
        {
            // TODO: Add insert logic here

            return RedirectToAction("Index");
        }
        catch
        {
            return View();
        }
    }

1 个答案:

答案 0 :(得分:0)

请分享您的route.config文件,这可能有助于解决此问题。  以防万一也尝试从Html.BeginForm()中删除周界删除操作和控制器的名称。由于MVC具有强大的命名系统,因此我们不需要添加该信息。

如果上述内容未解决您的问题,请分享您的路线文件。