Using ActionResults
In this recipe, you will learn what ActionResults
we will use in an MVC-compliant application.
Getting ready
We created an empty web application with VS 2017 and added to it an empty controller. We'll create a repository with hardcoded values to be injected into the controller.
How to do it...
Here are all the types, the specific ActionResults
we can return from a controller action:
public virtual JsonResult Json(object data) public virtual ViewResult View() public virtual ViewComponentResult ViewComponent(string componentName) public virtual PartialViewResult PartialView() public virtual ChallengeResult Challenge() public virtual ForbidResult Forbid() public virtual SignInResult SignIn(ClaimsPrincipal principal, string authenticationScheme) public virtual SignOutResult SignOut(params string[] authenticationSchemes) public virtual ContentResult Content(string content) public virtual FileContentResult File(byte[] fileContents, string contentType) public virtual FileStreamResult...