asp.net mvc - "Cannot redirect after HTTP headers have been sent" when doing RedirectToAction() -


so question little different others. others, using response.redirect( url ); directly , fixes wrapping around it.

however, have following inside same controller:

public actionresult index() {   // other logic running inside function...    return redirecttoaction( "result" ); }  public actionresult result() {    // expecting calls being sent index    return view ("done"); } 

so not calling response.redirect() directly, redirecttoaction() calls response.redirect() eventually. in case, can do?

these stack trace:

system exception: - message: cannot redirect after http headers have been sent. - source: system.web  - stack trace:    @ system.web.httpresponse.redirect(string url, boolean endresponse, boolean permanent)    @ system.web.httpresponsewrapper.redirect(string url, boolean endresponse)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultfilterrecursive(ilist`1 filters, int32 filterindex, resultexecutingcontext precontext, controllercontext controllercontext, actionresult actionresult)    @ system.web.mvc.controlleractioninvoker.invokeactionresultwithfilters(controllercontext controllercontext, ilist`1 filters, actionresult actionresult)    @ system.web.mvc.async.asynccontrolleractioninvoker.<>c__displayclass21.<begininvokeaction>b__1e(iasyncresult asyncresult) 

call response.headers.clear() before redirecttoaction


Comments

Popular posts from this blog

aws api gateway - SerializationException in posting new Records via Dynamodb Proxy Service in API -

asp.net - Problems sending emails from forum -