I am getting this error: Cannot redirect after HTTP headers have been sent.
This is happening when I hit the "confirm" button in the last step of the One Page Checkout. It tries to find PayPal to let the user pay and it is giving me an error about how Paypal.com couldn't be found because of a DNS issue. I looked in my log and I see whenever this happens, the above error (Cannot redirect after HTTP headers have been sent) shows up. How can I fix this?
System.Web.HttpException (0x80004005): Cannot redirect after HTTP headers have been sent. at System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent) at System.Web.HttpResponseWrapper.Redirect(String url, Boolean endResponse) at System.Web.Mvc.RedirectToRouteResult.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<InvokeActionResultWithFilters>b__19() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilter(IResultFilter filter, ResultExecutingContext preContext, Func`1 continuation) at System.Web.Mvc.ControllerActionInvoker.<>c__DisplayClass1c.<>c__DisplayClass1e.<InvokeActionResultWithFilters>b__1b() at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) at System.Web.Mvc.Controller.ExecuteCore() at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) at System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0() at System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) at System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() at System.Web.Mvc.MvcHandler.<>c__DisplayClasse.<EndProcessRequest>b__d() at System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>b__0(Action f) at System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) at System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult result) at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I too have started getting the 'Cannot redirect after HTTP headers have been sent.' error when redirecting to my payment provider.
I am unsure what I am meant to do, I have looked through the link Andrei posted above, have enabled errors but just get a white screen whilst on... http://www.sitename.com/checkout/OpcCompleteRedirectionPayment
What am I missing?
I think I started getting this on my local host version of 2.30 all of a sudden, and now still getting it on 2.40
Hi, I'm getting the same error. When I try and checkout using the PayPoint plugin, I get a blank page and an error in my Log table:
"Cannot redirect after HTTP headers have been sent."
Stepping through the code, it falls through OpcCompleteRedirectionPayment action within the CheckoutController.
This then gets down to _paymentService.PostProcessPayment(postProcessPaymentRequest);
This falls through to the PostProcessPayment method within the PayPointPaymentProcessor.cs file which builds a RemotePost and is meant to POST away to PayPoint.
Stepping through the RemotePost.Post() method, it builds up the HTML form and ends with a _httpContext.Response.End() however, it is then continuing back to the CheckoutController and doing the 2.50 fix:
if (this.Response.IsRequestBeingRedirected) { //redirection has been done in PostProcessPayment return Content("Redirected"); } else { //if no redirection has been done (to a third-party payment page) //theoretically it's not possible return RedirectToRoute("CheckoutCompleted"); }
However, this.Response.IsRequestBeingRedirected is false so it's falling through the RedirectToRoute, causing the Log error.
Shouldn't it not even reach that point? It doesn't appear to be doing the POST at all.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.