是否有所有 ASP.Net MVC 操作结果及其用途的列表?
我一直忙于为几乎所有事情使用 ActionResult,但我知道这是不正确的,我应该使用更具体的操作结果。
我用 Google 搜索了这个但找不到列表。我们刚买了 Wrox 这本书,但距离交付还有一个多星期,我想在那之前好好阅读一下。
您也可以推出自己的产品吗?是否在某处记录了这一点?
最佳答案
如果您使用 Reflector 打开 System.Web.Mvc
,你会看到有几个派生类型继承自抽象类ActionResult。它们是:
System.Web.Mvc.ContentResult
System.Web.Mvc.EmptyResult
System.Web.Mvc.FileResult
System.Web.Mvc.FileContentResult
System.Web.Mvc.FilePathResult
System.Web.Mvc.FileStreamResult
System.Web.Mvc.HttpUnauthorizedResult
System.Web.Mvc.JavaScriptResult
System.Web.Mvc.JsonResult
System.Web.Mvc.RedirectResult
System.Web.Mvc.RedirectToRouteResult
System.Web.Mvc.ViewResultBase
System.Web.Mvc.PartialViewResult
System.Web.Mvc.ViewResult
是的,您可以通过从抽象类 ActionResult 继承来自己滚动。您可以使用 Reflector 研究上面列表中的一个或多个 ActionResult,以了解如何完成此操作。
源代码也可以在这里找到:
http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471
关于c# - 什么是 ASP.Net MVC 操作结果?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1490548/