2
public ActionResult CreateSomething()
{
return View("ViewName", new CreateSomeDto());
}
我只是在一些遗留代码中遇到这样的:
public ActionResult CreateSomething()
{
return RenderView("ViewName", new CreateSomeDto());
}
可能有人请解释一下有什么区别?
嗯...'偏'铃响了。这可能与ajax/JavaScript有关吗?我的问题是,获取请求命中CreateSomething动作,但包含获取请求链接的前端页面根本没有改变 - 也许路由被搞砸了。无论如何,我认为我可以安全地用View替换RenderView? – cs0815 2013-03-01 18:23:59
@csetzkorn由于您使用的是更新版本的MVC,并且您的操作方法返回ActionResult,因此您可以简单地返回一个View。 – 2013-03-01 18:59:29