小编lia*_*iam的帖子

RedirectToAction MVC2的问题 - 无法将类型'System.Web.Mvc.RedirectToRouteResult'隐式转换为'System.Web.Mvc.ViewResult'

我在尝试使用RedirectToAction时收到此错误,任何人都可以提供有关为什么会发生这种情况的任何建议,我之前使用过这个没有任何问题,我一定是缺少一些东西.

无法将类型'System.Web.Mvc.RedirectToRouteResult'隐式转换为'System.Web.Mvc.ViewResult'

 [HttpPost]
    public ViewResult Edit(Customer customer)
    {
        if (ModelState.IsValid)
        {
            customersRepository.SaveCustomer(customer);
            TempData["message"] = customer.CustomerName + " has been saved.";
            return RedirectToAction("Index");
        }

        else //validation error, so redisplay the same view
            return View(customer);

    }
Run Code Online (Sandbox Code Playgroud)

问候

利亚姆

asp.net redirecttoaction asp.net-mvc-2

14
推荐指数
1
解决办法
9805
查看次数

标签 统计

asp.net ×1

asp.net-mvc-2 ×1

redirecttoaction ×1