I'm pushing a PEM file towards my website user for download. here is the code:
try { FileStream sourceFile = null; Response.ContentType = "application/text"; Response.AddHeader("content-disposition", "attachment; filename=" + Path.GetFileName(RequestFilePath)); sourceFile = new FileStream(RequestFilePath, FileMode.Open); long FileSize = sourceFile.Length; byte[] getContent = new byte[(int)FileSize]; sourceFile.Read(getContent, 0, (int)sourceFile.Length); sourceFile.Close(); Response.BinaryWrite(getContent); } catch (Exception exp) { throw new Exception("File save error! Message:<br />" + exp.Message, exp); } The issue is that the file that is downloaded has the content that should be there + a copy of the whole web page's HTML too.
Whats happening here?