core
core copied to clipboard
Redirect to new route OnActionExecuting method MVC .NET CORE 5
Description
I have an issue that the request redirected too many times and I just want to go to new redirect route, so how can I prevent that or is there something that I am not aware of?
this my code
public class AuthController : Controller
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
base.OnActionExecuting(filterContext);
if (GoToLogin)
{
filterContext.Result = new RedirectToRouteResult(new RouteValueDictionary
{
{"controller", "account"},
{"action", "login"}
});
}
}
Configuration
.NET 5