Vnu*_*uuk 18 c# asp.net-mvc asp.net-core
我刚刚下载了基于ASP.NET 5的音乐商店(microsoft sample projct)源代码.我不明白为什么Microsoft的开发人员使用IActionResult接口作为控制器中的返回类型.
IActionResult接口使用的原因是什么?为什么不使用ActionResult类型.
R. *_*ury 30
看到这个帖子关于IActionResult与ActionResult:http://forums.asp.net/post/5980446.aspx
IActionResult允许更广泛的返回类型,包括实现IActionResult接口的任何自定义代码. ActionResult仅限于那些扩展ActionResult抽象类的类(您也可以使用自定义代码,但使用接口允许多重继承,而扩展类则不会).
| 归档时间: |
|
| 查看次数: |
15388 次 |
| 最近记录: |