Is there any circumstance that the red can be called given the green?
That looks like unit test coverage, which should still reach the code since the method itself hasn't returned. However, if the automated testing you're using actually participates in the HTTP context, then it won't reach that other code if the response has ended.
You can prevent the response from ending by passing false
to Redirect()
:
Response.Redirect(PageRedirect, false);
However, this is probably a bad idea. Consider the logical flow of what this code is doing. A redirect should end the response. You can choose not to end it if there's more server-side processing to be done, but this can often be pretty unintuitive. But if that server-side processing is another redirect, what is that even supposed to do? Redirect the user twice? Redirect once and ignore the second? Ignore the first and perform the second redirect? It's pretty unintuitive.
I'd recommend organizing the code such that the response terminates in the redirect. While it's not technically a return
from the method, in this context it really should be logically treated like one.