473,386 Members | 1,973 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Newbe question ---- response.writefile

oz
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?
Nov 19 '05 #1
1 1151
oz
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
}
}
Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.