何时从 Controller 返回“EmptyResult()”是个好主意
最佳答案
你基本上会用它来表示你没有对某个 Action 做任何事情 结果。
来自 MSDN:
Represents a result that does nothing, such as a controller action method that returns nothing.
我个人在 AsyncController
中定义的操作上使用过,所以如果您有一个异步操作,例如:
public void SendMailAsync() { }
基本上是 AsnycController
中的一个操作,您还需要一个 xxxCompleted 操作(按照惯例)
public virtual ActionResult SendMailCompleted
{
// do whatever
return new EmptyResult();
}
由于这不是一个由用户调用的操作,而是由后台任务调用的操作,因此我不会对结果执行任何操作。
关于asp.net-mvc-3 - MVC3 = >> return EmptyResult() 什么时候返回这个是个好主意?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5452172/