string returnUrl = "/occupychristmas.org/content/;WebUtil.Redirect(returnUrl);However, the the last line over seems to throw an exception below:
6156 2016:11:18 06:41:01 ERROR applications error.Exception: System.Web.HttpExceptionMessage: cannot redirect ~ HTTP headers have actually been sent.Source: System.Web in ~ System.Web.HttpResponse.Redirect(String url, Boolean endResponse, Boolean permanent) in ~ occupychristmas.org.Web.WebUtil.Redirect(String path)Any idea what could be throwing this excpetion?
enhance this question
request Nov 21 "16 at 4:58
Nil PunNil Pun
2,1511515 silver badges3535 bronze title
add a comment |
1 answer 1
energetic earliest Votes
This exception can take place in at least 2 cases:
There is currently a redirect that has been initiated earlier throughout the web page request.
You are watching: Cannot redirect after http headers have been sent
Your application wrote other headers come the response before WebUtil.Redirect was called.
In both cases, you should acquire a clue about what"s happening by setup a breakpoint top top the line with WebUtil.Redirect and also looking at the values stored in Response.Headers.
If there"s already a redirect header, the ideal thing to perform is make certain your redirection reasonable is consolidated in one place—then there won"t it is in room because that such errors.
If you can"t regulate previous redirects, climate you can guard against them:
if (!Response.IsRequestBeingRedirected) wire returnUrl = "/occupychristmas.org/content/"; WebUtil.Redirect(returnUrl);
boost this prize
answer Nov 21 "16 at 6:53
Dmytro ShevchenkoDmytro Shevchenko
12.4k22 gold badges3838 silver badges8787 bronze title
include a comment |
thanks for contributing an answer to occupychristmas.org ridge Exchange!Please be sure to answer the question. Provide details and also share your research!
But avoid …Asking for help, clarification, or responding to various other answers.Making statements based on opinion; ago them up with recommendations or an individual experience.
To find out more, check out our tips on writing an excellent answers.
See more: Meek Mill And Friends Concert S 2022 & 2021, Meek Mill Brings Out Rick Ross, Dmx, T
Sign up or log in
sign up utilizing Google
authorize up making use of Facebook
sign up making use of Email and also Password
Post together a guest
email Required, but never shown
Post together a guest
Required, however never shown
write-up Your prize Discard
Not the prize you're feather for? Browse various other questions tagged redirect or questioning your very own question.
The Overflow Blog
Featured ~ above Meta
hot Network concerns an ext hot questions
i ordered it to RSS
question feed To i ordered it to this RSS feed, copy and also paste this URL into your RSS reader.
stack Exchange Network
site style / logo design © 2021 stack Exchange Inc; user contributions license is granted under cc by-sa. Rev2021.9.17.40238