Skip to content

Handler Results

Andrew Bullock edited this page Oct 30, 2017 · 3 revisions

Result Types

There are many types of IResult, the most common being ViewResult, JsonResult and RedirectResult.

ViewResults are best created using the Handler.View() method.

RedirectResults are best created using the static methods on RedirectResult, e.g.:

RedirectResult.SeeOther("/elsewhere");

JsonResults are best created using its constructor, e.g.

new JsonResult(new { foo = "bar" });

Status Codes

To return a non-200 status code, set it on the IResult you're returning. You almost never need to talk directly to IResponse:

var result = View("foo");
result.StatusCode = 418;
return result;

TODO

Clone this wiki locally