I have an ASPX (PictureGetter.aspx) That loads images and writes them to the response in a manner such as this:
private void WritePicture()
{
byte[] bytes = GetBytes(picPath);
Response.ContentType = "image/jpeg";
Response.Clear();
Response.BinaryWrite(bytes);
Response.End();
}
This can then be used on pages like so:
<img src="/path/to/PictureGetter.aspx?some_param=some_value" />
However, for certain scenarios, I won't be able to get an image, so I'd like to redirect the user to an entirely different page:
if (some_condition)
{
Response.Redirect("/another/path/page.aspx");
}
else
{
WritePicture();
}
However, the redirection never occurs. I've tried Response.Redirect("/another/path/page.aspx", false) and Response.Redirect("/another/path/page.aspx", true) but to no avail. Any ideas how I could fix this?