> AutoEventWireup set to true? Check the "Web Form Designer Generated code"
region to see if Page_Load is attached twice to the Load event..
Hans Kesting
Where do I set AutoEventWireup? I didn't attach Page_Load twice, so that
can't be it. Below my full code... if I step through Page_Load, after
Response.End() it jumps back to byte[] myPdf = GetPdf(); instead of showing
the pdf in my browser window. Any other ideas?? Thanks.
using System;
using System.IO;
namespace WebForm1
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
byte[] myPdf = GetPdf();
Response.Clear();
Response.Buffer= true;
Response.ContentType = "application/pdf";
Response.BinaryWrite(myPdf);
Response.Flush();
Response.End();
}
private byte[] GetPdf()
{
//Code to get pdf from disk
FileStream MyFileStream;
long FileSize;
MyFileStream = new FileStream(@"C:\somefile.pdf", FileMode.Open);
FileSize = MyFileStream.Length;
byte[] Buffer = new byte[(int)FileSize];
MyFileStream.Read(Buffer, 0, (int)FileSize);
MyFileStream.Close();
return Buffer;
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}