Sometimes I get exception in my production environment:
- Process information
- Process ID: 3832
- Pr
You are actually trying to redirect a page which has some response to throw. So first you keep the information you have throw in a buffer using response.buffer = true
in beginning of the page and then flush it when required using response.flush
this error will get fixed
How about checking this before doing the redirect:
if (!Response.IsRequestBeingRedirected)
{
//do the redirect
}
İf someone still having this problem.Try to use instead of ovverriding
public void OnActionExecuting(ActionExecutingContext context)
{
try
{
if (!HttpContext.Current.User.Identity.IsAuthenticated)
{
if (!HttpContext.Current.Response.IsRequestBeingRedirected)
{
context.Result = new RedirectToRouteResult(
new RouteValueDictionary { { "controller", "Login" }, { "action", "Index" } });
}
}
}
catch (Exception ex)
{
new RouteValueDictionary { { "controller", "Login" }, { "action", "Index" } });
}
}
We were getting the same error - so this may be useful to some.
For us the cause was super simple. An interface change confused an end user and they were pressing the back button in the browser at a 'bad' time after a form submission (sure we should probably have used a PRG pattern, but we didn't).
We fixed the issue and the user is no longer pressing the back button. Problem solved.