asp.net – RedirectToAction MVC2的问题 – 不能将类型“System.Web.Mvc.Re
发布时间:2020-05-24 05:58:25 所属栏目:asp.Net 来源:互联网
导读:在尝试使用RedirectToAction时,我收到此错误,任何人都可以提供任何建议,为什么会发生这种情况,呃在没有任何问题的情况下使用这个错误,我一定是缺少一些东西. 不能将类型“System.Web.Mvc.RedirectToRouteResult”隐式转换为“System.Web.Mvc.ViewResult” [Ht
|
在尝试使用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);
}
问候 利亚姆 解决方法尝试将公共ViewResult Edit(客户客户)更改为public ActionResult Edit(客户客户)ViewResult派生自ActionResult,只能返回视图.由于您的代码可以返回View或重定向,因此您应该使用ActionResult.有关详细信息,请参阅this answer. (编辑:安卓应用网) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net vb用户控件在调用页面上引发一个事件
- 部署DotNetNuke并将ASP.NET应用程序分开 – 可能的问题?
- asp.net-mvc – 在ASP.NET会话中存储任何内容导致500ms延迟
- asp.net-mvc – 将ViewData传递给RenderPartial
- asp.net-web-api – 在WebApi和MVC项目之间共享SignalR集线
- 在ASP.net中复制PHPBB密码哈希c#
- asp.net-mvc-3 – ASP.NET MVC3 – 分开的程序集中的区域
- asp.net – 你的aspx页面中的内联代码是一个好习惯吗?
- asp.net – Service Fabric中的.NET Core RC2
- asp.net – 动态更改GridView项目模板
推荐文章
站长推荐
- asp.net – web.config在文件夹允许全部或没有用
- asp.net-mvc – 如何设置TextBox的空字符串而不是
- 在ASP.NET Core 2.0 / Angular模板应用程序上发布
- ASP.NET MVC:从FileResult返回大量数据
- asp.net – 如何使用Log4Net启用IP地址记录
- asp.net – DNN vs Composite C1 – Pro and Con
- asp.net – 从1.7到1.9的迷你探查器升级破坏了现
- asp.net – MSCharts“没有找到HTTP请求类型”GE
- 强制ASP.NET应用程序从bin而不是GAC加载程序集
- ASP.NET会话已过期或无法找到 – 因为Session.Se
热点阅读
