是否有所有的ASP.Net MVC行动的结果和他们的用途清单?
我一直在忙于用的ActionResult几乎一切,但我知道这不是正确的,我应该使用更具体的行动结果。
我GOOGLE了这一点,但无法找到一个列表。 我们刚刚买了Wrox的书,但它是一个多星期远离交货,我想在此之前该井读了。
你也可以推出自己的,并且是记录在案的地方?
是否有所有的ASP.Net MVC行动的结果和他们的用途清单?
我一直在忙于用的ActionResult几乎一切,但我知道这不是正确的,我应该使用更具体的行动结果。
我GOOGLE了这一点,但无法找到一个列表。 我们刚刚买了Wrox的书,但它是一个多星期远离交货,我想在此之前该井读了。
你也可以推出自己的,并且是记录在案的地方?
如果您打开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滚你自己的。 你可以研究一个或多个ActionResults的列表上面反射来感受一下如何做到这一点来完成。
源代码也可以在这里:
http://aspnet.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=24471
如果你正在寻找这件事的ASP.NET MVC 5,添加HttpStatusCodeResult到列表中。
此外,它是值得一提的是辅助方法返回的相应作用的结果,没有单词“结果”结尾。 例如,要返回HttpNotFoundResult,你会写返回HttpNotFound(“状态描述”); 。
在MSDN上的ActionResult类网页有结果类和辅助方法的完整列表。