473,915 Members | 5,813 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Transmit File AND HTML in Response

The standard method to transmit a file from an aspx page to a browser
is to stream the file to the response then end the response. The HTML
code generated by the aspx page is discarded, and the browser displays
or offers to save the binary file instead.

I would like to have the browser accept and display the revised HTML
code as well as offering to open or save the attached file. This
SHOULD be possible using a multipart MIME format - one part is declared
with a Content-Disposition of inline and a Content-Type of text/html,
and a second part with a Content-Disposition of attachment and a
Content-Type of application/octet-stream.

However, I haven't been able to get a valid multipart response out of
my aspx page (using multipart/mixed or multipart/x-mixed-replace). The
Page wrapper seems to be hard-coded to creating and sending headers
that are incompatible with this approach.

Has anyone succesfully done something like this? My example code is
below, which is a simple page that displays a file and updates a view
count. When the page is refreshed, the view count increments. When a
file is displayed, the view count is incremented in code but the
revised HTML is not sent to the browser, so you don't see the textbox
change. Also, since the ViewState is not updated in the browser, the
view count goes back to it's previous state when you next refresh.

I've tried removing the Response.End() at the end of the ShowDocument
method, but bad things happen (the next button click generates a
bizarre page that has the html code displayed twice with a partial HTTP
header between them...). I also tried manually setting the
Response.Conten tType to multipart/mixed and writing the boundary
between the HTML output and the file streaming, but I couldn't change
the ContentType after the inital headers had been sent.

Thanks for any ideas...

John H.
== WebForm1.aspx ==

<%@ Page language="c#" Codebehind="Web Form1.aspx.cs"
AutoEventWireup ="false" Inherits="ShowD ocumentTest.Web Form1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name=vs_default ClientScript content="JavaSc ript">
<meta name=vs_targetS chema
content="http://schemas.microso ft.com/intellisense/ie5">
</head>
<body >
<form id="Form1" method="post" runat="server">
<p><asp:TextB ox id="TextBox1" runat="server"
Width="400px"></asp:TextBox></p>
<p><asp:LinkBut ton id="btnPDF" runat="server"> Show
file</asp:LinkButton> </p>
<p><asp:Butto n id="Button1" runat="server"
Text="Refresh"> </asp:Button></p>
</form>
</body>
</html>
== WebForm1.aspx.c s ==

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

namespace ShowDocumentTes t
{
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Link Button btnPDF;
protected System.Web.UI.W ebControls.Text Box TextBox1;
protected System.Web.UI.W ebControls.Butt on Button1;

private int viewCount = 0;

private void Page_Load(objec t sender, System.EventArg s e)
{
if (IsPostBack)
viewCount = (int)(ViewState["viewCount"]);
viewCount++;
ViewState["viewCount"] = viewCount;
TextBox1.Text = "You've seen this " + viewCount + " times";
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.btnPDF.Cli ck += new System.EventHan dler(this.btnPD F_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void btnPDF_Click(ob ject sender, System.EventArg s e)
{
ShowDocument(Re quest.MapPath(" files") + Path.DirectoryS eparatorChar
+ "example.pd f");
}

private void ShowDocument(st ring filePath)
{
FileInfo fi = new FileInfo(filePa th);
string fileName = Path.GetFileNam e(filePath);

Response.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ; filename=\""
+ fileName + "\"");
Response.AddHea der("Content-Length", fi.Length.ToStr ing());

byte[] buffer = new byte[1024];
long byteCount;
FileStream inStr = File.OpenRead(f ilePath);

while ((byteCount = inStr.Read(buff er, 0, buffer.Length)) > 0)
{
if(Response.IsC lientConnected)
{
Response.Output Stream.Write(bu ffer, 0, (int)(byteCount ));
Response.Flush( );
}
else
break;
}
inStr.Close();
Response.End();
}
}
}

May 10 '06 #1
6 7412
Tested your code in VS.NET 2005 to see if any difference but I see none
I would love to see a solution for this one.

Have you tried different possibilities

call JavaScript to get you the incremented number ( via AJAX, Web services
via JavaScript ) or get back the data then afterwards get a file via a
second page ( Target = _blank ) dedicated to get files for you?

Just thinking... Sorry for the lack of help here.

SA
<jo**@haasbeek. com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
The standard method to transmit a file from an aspx page to a browser
is to stream the file to the response then end the response. The HTML
code generated by the aspx page is discarded, and the browser displays
or offers to save the binary file instead.

I would like to have the browser accept and display the revised HTML
code as well as offering to open or save the attached file. This
SHOULD be possible using a multipart MIME format - one part is declared
with a Content-Disposition of inline and a Content-Type of text/html,
and a second part with a Content-Disposition of attachment and a
Content-Type of application/octet-stream.

However, I haven't been able to get a valid multipart response out of
my aspx page (using multipart/mixed or multipart/x-mixed-replace). The
Page wrapper seems to be hard-coded to creating and sending headers
that are incompatible with this approach.

Has anyone succesfully done something like this? My example code is
below, which is a simple page that displays a file and updates a view
count. When the page is refreshed, the view count increments. When a
file is displayed, the view count is incremented in code but the
revised HTML is not sent to the browser, so you don't see the textbox
change. Also, since the ViewState is not updated in the browser, the
view count goes back to it's previous state when you next refresh.

I've tried removing the Response.End() at the end of the ShowDocument
method, but bad things happen (the next button click generates a
bizarre page that has the html code displayed twice with a partial HTTP
header between them...). I also tried manually setting the
Response.Conten tType to multipart/mixed and writing the boundary
between the HTML output and the file streaming, but I couldn't change
the ContentType after the inital headers had been sent.

Thanks for any ideas...

John H.
== WebForm1.aspx ==

<%@ Page language="c#" Codebehind="Web Form1.aspx.cs"
AutoEventWireup ="false" Inherits="ShowD ocumentTest.Web Form1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name=vs_default ClientScript content="JavaSc ript">
<meta name=vs_targetS chema
content="http://schemas.microso ft.com/intellisense/ie5">
</head>
<body >
<form id="Form1" method="post" runat="server">
<p><asp:TextB ox id="TextBox1" runat="server"
Width="400px"></asp:TextBox></p>
<p><asp:LinkBut ton id="btnPDF" runat="server"> Show
file</asp:LinkButton> </p>
<p><asp:Butto n id="Button1" runat="server"
Text="Refresh"> </asp:Button></p>
</form>
</body>
</html>
== WebForm1.aspx.c s ==

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

namespace ShowDocumentTes t
{
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Link Button btnPDF;
protected System.Web.UI.W ebControls.Text Box TextBox1;
protected System.Web.UI.W ebControls.Butt on Button1;

private int viewCount = 0;

private void Page_Load(objec t sender, System.EventArg s e)
{
if (IsPostBack)
viewCount = (int)(ViewState["viewCount"]);
viewCount++;
ViewState["viewCount"] = viewCount;
TextBox1.Text = "You've seen this " + viewCount + " times";
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.btnPDF.Cli ck += new System.EventHan dler(this.btnPD F_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void btnPDF_Click(ob ject sender, System.EventArg s e)
{
ShowDocument(Re quest.MapPath(" files") + Path.DirectoryS eparatorChar
+ "example.pd f");
}

private void ShowDocument(st ring filePath)
{
FileInfo fi = new FileInfo(filePa th);
string fileName = Path.GetFileNam e(filePath);

Response.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ; filename=\""
+ fileName + "\"");
Response.AddHea der("Content-Length", fi.Length.ToStr ing());

byte[] buffer = new byte[1024];
long byteCount;
FileStream inStr = File.OpenRead(f ilePath);

while ((byteCount = inStr.Read(buff er, 0, buffer.Length)) > 0)
{
if(Response.IsC lientConnected)
{
Response.Output Stream.Write(bu ffer, 0, (int)(byteCount ));
Response.Flush( );
}
else
break;
}
inStr.Close();
Response.End();
}
}
}

May 10 '06 #2
couple of issues. there is only one content-type header, and headers come
before content, so you can not change them after you started a download
(they have been written).

when set the content-type, you include the boundry header. then you need to
write out the content, with content headers and boundries:

Content-type: multipart/mixed; boundary=23xx12 11
CRLF
--23xx1211
Content-type: text/html
CRLF
..... html document data .(first "part" of the message)...
--23xx1211
Content-type: audio/aiff
CRLF
...... audio data ..... (second "part" of the message)....
--23xx1211--

now. most browsers see multipart.mixed as a replacement for server push, and
multipart/related as a mail messages with inline content such as audio and
images. they will save the whole page or display, i don't know if it will do
what you want.

-- bruce (sqlwork.com)

<jo**@haasbeek. com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
The standard method to transmit a file from an aspx page to a browser
is to stream the file to the response then end the response. The HTML
code generated by the aspx page is discarded, and the browser displays
or offers to save the binary file instead.

I would like to have the browser accept and display the revised HTML
code as well as offering to open or save the attached file. This
SHOULD be possible using a multipart MIME format - one part is declared
with a Content-Disposition of inline and a Content-Type of text/html,
and a second part with a Content-Disposition of attachment and a
Content-Type of application/octet-stream.

However, I haven't been able to get a valid multipart response out of
my aspx page (using multipart/mixed or multipart/x-mixed-replace). The
Page wrapper seems to be hard-coded to creating and sending headers
that are incompatible with this approach.

Has anyone succesfully done something like this? My example code is
below, which is a simple page that displays a file and updates a view
count. When the page is refreshed, the view count increments. When a
file is displayed, the view count is incremented in code but the
revised HTML is not sent to the browser, so you don't see the textbox
change. Also, since the ViewState is not updated in the browser, the
view count goes back to it's previous state when you next refresh.

I've tried removing the Response.End() at the end of the ShowDocument
method, but bad things happen (the next button click generates a
bizarre page that has the html code displayed twice with a partial HTTP
header between them...). I also tried manually setting the
Response.Conten tType to multipart/mixed and writing the boundary
between the HTML output and the file streaming, but I couldn't change
the ContentType after the inital headers had been sent.

Thanks for any ideas...

John H.
== WebForm1.aspx ==

<%@ Page language="c#" Codebehind="Web Form1.aspx.cs"
AutoEventWireup ="false" Inherits="ShowD ocumentTest.Web Form1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name=vs_default ClientScript content="JavaSc ript">
<meta name=vs_targetS chema
content="http://schemas.microso ft.com/intellisense/ie5">
</head>
<body >
<form id="Form1" method="post" runat="server">
<p><asp:TextB ox id="TextBox1" runat="server"
Width="400px"></asp:TextBox></p>
<p><asp:LinkBut ton id="btnPDF" runat="server"> Show
file</asp:LinkButton> </p>
<p><asp:Butto n id="Button1" runat="server"
Text="Refresh"> </asp:Button></p>
</form>
</body>
</html>
== WebForm1.aspx.c s ==

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

namespace ShowDocumentTes t
{
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Link Button btnPDF;
protected System.Web.UI.W ebControls.Text Box TextBox1;
protected System.Web.UI.W ebControls.Butt on Button1;

private int viewCount = 0;

private void Page_Load(objec t sender, System.EventArg s e)
{
if (IsPostBack)
viewCount = (int)(ViewState["viewCount"]);
viewCount++;
ViewState["viewCount"] = viewCount;
TextBox1.Text = "You've seen this " + viewCount + " times";
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.btnPDF.Cli ck += new System.EventHan dler(this.btnPD F_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void btnPDF_Click(ob ject sender, System.EventArg s e)
{
ShowDocument(Re quest.MapPath(" files") + Path.DirectoryS eparatorChar
+ "example.pd f");
}

private void ShowDocument(st ring filePath)
{
FileInfo fi = new FileInfo(filePa th);
string fileName = Path.GetFileNam e(filePath);

Response.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ; filename=\""
+ fileName + "\"");
Response.AddHea der("Content-Length", fi.Length.ToStr ing());

byte[] buffer = new byte[1024];
long byteCount;
FileStream inStr = File.OpenRead(f ilePath);

while ((byteCount = inStr.Read(buff er, 0, buffer.Length)) > 0)
{
if(Response.IsC lientConnected)
{
Response.Output Stream.Write(bu ffer, 0, (int)(byteCount ));
Response.Flush( );
}
else
break;
}
inStr.Close();
Response.End();
}
}
}

May 10 '06 #3
Bruce,

You seem to know what you are talking about.
How do you make the example below to work.

Are you saying that:
Response.Conten tType = "multipart/mixed";

Since I never done this before, Where do you add the boundary??

Response.Conten tType = "multipart/mixed; boundary=23xx12 11"; ???
Response.AddHea der("Content-Disposition", "attachment ; filename=\"" +
fileName + "\"");
Response.AddHea der("Content-Length", fi.Length.ToStr ing());
Response.Write( "CRLF");
Response.Write( "--23xx1211");
Response.Write( "Content"); etc...

Response.Conten tType = "text/html";
Response.AddHea der("Content-?????"");
Response.AddHea der("Content-Length", ????);
Response.Write( "CRLF");
Response.Write( "--23xx1211");
Response.Write( "Content"); etc...
Corrections and/or a working example will be great.

Thank you Bruce,

SA

"bruce barker (sqlwork.com)" <b_************ *************@s qlwork.com> wrote
in message news:eF******** ********@TK2MSF TNGP02.phx.gbl. ..
couple of issues. there is only one content-type header, and headers come
before content, so you can not change them after you started a download
(they have been written).

when set the content-type, you include the boundry header. then you need
to write out the content, with content headers and boundries:

Content-type: multipart/mixed; boundary=23xx12 11
CRLF
--23xx1211
Content-type: text/html
CRLF
.... html document data .(first "part" of the message)...
--23xx1211
Content-type: audio/aiff
CRLF
..... audio data ..... (second "part" of the message)....
--23xx1211--

now. most browsers see multipart.mixed as a replacement for server push,
and multipart/related as a mail messages with inline content such as audio
and images. they will save the whole page or display, i don't know if it
will do what you want.

-- bruce (sqlwork.com)

<jo**@haasbeek. com> wrote in message
news:11******** *************@g 10g2000cwb.goog legroups.com...
The standard method to transmit a file from an aspx page to a browser
is to stream the file to the response then end the response. The HTML
code generated by the aspx page is discarded, and the browser displays
or offers to save the binary file instead.

I would like to have the browser accept and display the revised HTML
code as well as offering to open or save the attached file. This
SHOULD be possible using a multipart MIME format - one part is declared
with a Content-Disposition of inline and a Content-Type of text/html,
and a second part with a Content-Disposition of attachment and a
Content-Type of application/octet-stream.

However, I haven't been able to get a valid multipart response out of
my aspx page (using multipart/mixed or multipart/x-mixed-replace). The
Page wrapper seems to be hard-coded to creating and sending headers
that are incompatible with this approach.

Has anyone succesfully done something like this? My example code is
below, which is a simple page that displays a file and updates a view
count. When the page is refreshed, the view count increments. When a
file is displayed, the view count is incremented in code but the
revised HTML is not sent to the browser, so you don't see the textbox
change. Also, since the ViewState is not updated in the browser, the
view count goes back to it's previous state when you next refresh.

I've tried removing the Response.End() at the end of the ShowDocument
method, but bad things happen (the next button click generates a
bizarre page that has the html code displayed twice with a partial HTTP
header between them...). I also tried manually setting the
Response.Conten tType to multipart/mixed and writing the boundary
between the HTML output and the file streaming, but I couldn't change
the ContentType after the inital headers had been sent.

Thanks for any ideas...

John H.
== WebForm1.aspx ==

<%@ Page language="c#" Codebehind="Web Form1.aspx.cs"
AutoEventWireup ="false" Inherits="ShowD ocumentTest.Web Form1" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
<head>
<title>WebForm1 </title>
<meta name="GENERATOR " Content="Micros oft Visual Studio .NET 7.1">
<meta name="CODE_LANG UAGE" Content="C#">
<meta name=vs_default ClientScript content="JavaSc ript">
<meta name=vs_targetS chema
content="http://schemas.microso ft.com/intellisense/ie5">
</head>
<body >
<form id="Form1" method="post" runat="server">
<p><asp:TextB ox id="TextBox1" runat="server"
Width="400px"></asp:TextBox></p>
<p><asp:LinkBut ton id="btnPDF" runat="server"> Show
file</asp:LinkButton> </p>
<p><asp:Butto n id="Button1" runat="server"
Text="Refresh"> </asp:Button></p>
</form>
</body>
</html>
== WebForm1.aspx.c s ==

using System;
using System.Collecti ons;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Web;
using System.Web.Sess ionState;
using System.Web.UI;
using System.Web.UI.W ebControls;
using System.Web.UI.H tmlControls;

namespace ShowDocumentTes t
{
public class WebForm1 : System.Web.UI.P age
{
protected System.Web.UI.W ebControls.Link Button btnPDF;
protected System.Web.UI.W ebControls.Text Box TextBox1;
protected System.Web.UI.W ebControls.Butt on Button1;

private int viewCount = 0;

private void Page_Load(objec t sender, System.EventArg s e)
{
if (IsPostBack)
viewCount = (int)(ViewState["viewCount"]);
viewCount++;
ViewState["viewCount"] = viewCount;
TextBox1.Text = "You've seen this " + viewCount + " times";
}

#region Web Form Designer generated code
override protected void OnInit(EventArg s e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeCompo nent();
base.OnInit(e);
}

/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeCompo nent()
{
this.btnPDF.Cli ck += new System.EventHan dler(this.btnPD F_Click);
this.Load += new System.EventHan dler(this.Page_ Load);

}
#endregion

private void btnPDF_Click(ob ject sender, System.EventArg s e)
{
ShowDocument(Re quest.MapPath(" files") + Path.DirectoryS eparatorChar
+ "example.pd f");
}

private void ShowDocument(st ring filePath)
{
FileInfo fi = new FileInfo(filePa th);
string fileName = Path.GetFileNam e(filePath);

Response.Conten tType = "applicatio n/octet-stream";
Response.AddHea der("Content-Disposition", "attachment ; filename=\""
+ fileName + "\"");
Response.AddHea der("Content-Length", fi.Length.ToStr ing());

byte[] buffer = new byte[1024];
long byteCount;
FileStream inStr = File.OpenRead(f ilePath);

while ((byteCount = inStr.Read(buff er, 0, buffer.Length)) > 0)
{
if(Response.IsC lientConnected)
{
Response.Output Stream.Write(bu ffer, 0, (int)(byteCount ));
Response.Flush( );
}
else
break;
}
inStr.Close();
Response.End();
}
}
}


May 10 '06 #4
That's exactly what I tried, but you will get an error on the second
attempt to set Response.Conten tType. In theory, you should be able to
set different content types for the different parts, hence the idea of
a part with a content type of application/octet-stream (the attached
file) and a second part with a content type of text/html (the HTML
page).

John H.

May 10 '06 #5
John,

Where do we go from here... waiting for Bruce if he has any other Ideas??
Are you thinking of other ways to do this?
What are your thoughts?
SA
"JohnH" <jo**@haasbeek. com> wrote in message
news:11******** **************@ g10g2000cwb.goo glegroups.com.. .
That's exactly what I tried, but you will get an error on the second
attempt to set Response.Conten tType. In theory, you should be able to
set different content types for the different parts, hence the idea of
a part with a content type of application/octet-stream (the attached
file) and a second part with a content type of text/html (the HTML
page).

John H.

May 10 '06 #6
I think the System.Web.Http Response class has some stuff in it that is
incompatible with the multipart response idea. That's the only place I
can think of that would prevent you from setting Response.Conten tType
more than once for a given response.

If I was doing this from scratch, I'd just write a class to generate
the full and correct MIME-formatted response message. So the first
thing I want to do is try that using a basic TCP socket program to send
such a message to a browser, and make sure that browsers actually
handle the multipart content correctly. If that works, I think I'll
have to figure out how to con the Page class into responding via this
new HttpMultiPartRe sponse class instead of the HttpResponse class that
the framework sets up for it.

This might be fun, but it won't be easy...

John H.

May 10 '06 #7

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

Similar topics

4
1584
by: Thomas Scheiderich | last post by:
I am just curious as to when it is better to use straight HTML or ASP (response.write) to put out HTML code on an ASP page. For example, if I have an ASP page that is including another ASP page, but the rest of the code is just HTML, which is the better way to do it. Here is my example: The file I am including in my ASP file (banner.asp). ******************************************************************
4
2208
by: M P | last post by:
Can you help me find an asp code that will upload a file from my PC to web server? Mark
1
2451
by: Bill Belliveau | last post by:
Hi all, This is partially a .NET question and partially scripting (whichever works :) I recently wrote a vCard parser that sends vCards directly to the brower as a stream. After the file is transmitted I need to close the window, but I can't get anything to works because I’m ‘hijacking’ the Response.Write method. Here is a small snippet of the code: string strDN = "CN=Brigit...
2
2018
by: Tom Youngquist | last post by:
I am trying to download a text file that my .NET page has just created based on entered parameters on the web page. Everything seems to work and the file is created. I am using the following code to start the download process: Response.Clear() Response.ContentType = "text/plain" Response.AppendHeader("Content-Disposition", "attachment; filename=" & fileName) Response.AppendHeader("Content-Description", "This is your Cost Journal...
10
1890
by: James_101 | last post by:
My training piece is in Authorware. The user logs in with last name and a four-digit number. Authorware sends this user identifier to an asp page called db_read.asp. This file sends a SQL SELECT command to a Microsoft Access database. The database returns either the record that was selected or a "no record" message. The db_read.asp file relays this information to Authorware. If a record was returned, Authorware displays it. If there...
5
1455
by: Eric Sabine | last post by:
I have a web site where the user is able to download a file. I can't use an anchor tag because I don't want the user to see where the filename is coming from. Below is the code in which the user clicks to get the file. I could swear this used to work but it definitely doesn't now. Each time at the Response.End() method, I get a System.Threading.ThreadAbortException. I'm not really sure why it is happening. Any clues? Eric Dim...
5
12329
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. On Beta1, I am able to execute a particular page with no problem, that page opens up in the comes up just fine. On Win2kdev1, when I go to execute the same page, it opens a file download dialog and asks me whether I want to open or save the...
5
3957
by: =?Utf-8?B?YzY3NjIyOA==?= | last post by:
Hi all, The following code was suggested by one of the users in this newsgroup when a pdf file was requested by a user from an asp page. I used the similar code in my page and the very interesting thing is when the pdf is displayed on the fly, the whole page is a gibberish code in stead of a normal pdf file. But it displays fine if I just use a link to a file on the page. Can you tell me what's the possible reason will cause this problem?...
15
9457
by: patf | last post by:
Hi - experienced programmer but this is my first Python program. This URL will retrieve an excel spreadsheet containing (that day's) msci stock index returns. http://www.mscibarra.com/webapp/indexperf/excel?priceLevel=0&scope=0&currency=15&style=C&size=36&market=1897&asOf=Jul+25%2C+2008&export=Excel_IEIPerfRegional Want to write python to download and save the file. So far I've arrived at this:
0
10039
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9881
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
11066
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10542
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9732
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5943
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
6148
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4344
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3368
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.