ASP.Net MVC控制器操作的返回void [英] ASP.Net MVC Controller Actions that return void
本文介绍了ASP.Net MVC控制器操作的返回void的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如果我有以下的控制器动作...
公共无效DoSomething的()
{
}
将在框架实际上它转换成这样?
公共EmptyResult DoSomething的()
{
返回新EmptyResult();
}
解决方案
是
返回void将产生一个EmptyResult的控制器。
块引用>从
拍摄If I have the following controller action...
public void DoSomething() { }
will the framework actually convert it to this?
public EmptyResult DoSomething() { return new EmptyResult(); }
解决方案Yes
A controller that returns void will produce an EmptyResult.
Taken from
The Life And Times of an ASP.NET MVC Controller
这篇关于ASP.Net MVC控制器操作的返回void的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文