ASP.NET Core MVC Interview Question #42

What is RedirectToActionResult?

Controllers, Actions, Model Binding & Action Results Junior Beginner

Quick Interview Answer

RedirectToActionResult instructs the browser to make a new request to an MVC action. It is commonly created with RedirectToAction and is heavily used with the Post/Redirect/Get pattern.

Detailed Explanation

RedirectToActionResult instructs the browser to make a new request to an MVC action. It is commonly created with RedirectToAction and is heavily used with the Post/Redirect/Get pattern.

Because it produces an HTTP redirect, data stored only in the current request's ViewData or ModelState does not automatically survive the new request.

Code Example

return RedirectToAction(
    nameof(Details),
    new { id = product.Id });