I have the following code
try
{
GetFileAndDisplay() // Gets the file from the server and writes the file in a Response stream
}
catch (UnauthorizedAccessException ex)
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "Msg", "<script type='text/javascript'>alert('Error')</script>");
Response.Clear();
Response.ContentType = "";
Response.End();
}
The file still gets downloaded for the client, albeit a corrupted file but is there a way to stop the file from downloading.
1 Answer