Handle with Redirect
Bitchiko Tchelidze edited this page Nov 12, 2017
·
1 revision
In some scenarios, in response to invalid ModelState
, we need to redirect request. To address this case we can use HandleInvalidModelWithRedirectActionFilterAttribute
.
[HttpGet]
[TypeFilter(typeof(HandleInvalidModelWithRedirectActionFilterAttribute), Arguments = new object[]
{
"/Shared/EntityNotFound"
})]
public IActionResult RedirectCaseOne(GetDetailsViewModel model)
=> View();
When posted GetDetailsViewModel
is not valid, request will be redirected to /Shared/EntityNotFound