Newbe question ---- response.writefile

G

Guest

private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
String FileName;
FileInfo MyFileInfo;
Long StartPos = 0, FileSize;
FileName = "J:\\Summary.txt";
MyFileInfo = new FileInfo(FileName);
FileSize = MyFileInfo.Length;

Response.Output.Write("Please Login: <br>");
Response.WriteFile(FileName, StartPos, FileSize);
}
}
}

put this in the page load event, then use view source from the brower. the
please login and content of the summary file are printed outside of the html
tags of the page? it also prints the "please login:" and content of the file
3 times????why?
 
G

Guest

hi,
here is the full source code of the cs codebehind file, the aspx file is
generic.

using System;
using System.Web;
using System.Web.UI;
using System.IO;

namespace MCAD315_3
{
/// <summary>
/// Summary description for WebForm1.
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
if(!IsPostBack)
{
String FileName;
FileInfo MyFileInfo;
long StartPos = 0, FileSize;
FileName = "J:\\Summary.txt";
MyFileInfo = new FileInfo(FileName);
FileSize = MyFileInfo.Length;

Response.Write("Please Login: <br>");
Response.WriteFile(FileName, StartPos, FileSize);
}

}

#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
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,734
Messages
2,569,441
Members
44,832
Latest member
GlennSmall

Latest Threads

Top