file download dialog coming twice

V

Vikram

i am using following code in button click... of asp.net code behind page

Response.Clear() 'clears the current output content from the buffer

Response.AppendHeader("Content-Disposition", _

"attachment; filename=Add2Calendar.vbs")

Response.AppendHeader("Content-Length", mStream.Length.ToString())

Response.ContentType = "application/download"

Response.BinaryWrite(mStream.ToArray())

Response.End()





but file download dialog comes twice if i select open at first time..

any solution to this
 
D

Daniel Fisher\(lennybacon\)

try it without Response.ContentType = "application/download" or use
Response.ContentType = "application/octetstream"
 
V

Vikram

It didnt work after doing what u said.
But it worked when i removed "attachment" from
Content-Disposition part.
 
R

Rob Meade

...
It didnt work after doing what u said.
But it worked when i removed "attachment" from
Content-Disposition part.

Give these a try:

' ContentType tells the browser what kind of file is coming.
' application/msword is a Microsoft Word document, eg:
' Response.ContentType = "application/msword"

Response.ContentType = "x-msdownload"

' Content-Disposition tells the browser how to handle the file, and what the
name
' of the file is. The "attachment" option tells the browser to open the Word
doc
' in a new instance of Microsoft Word, not in the browser Word plug-in

Response.AddHeader("Content-Disposition", "attachment;filename=""" +
fileName + """")
Response.AddHeader("Content-Length", New
System.IO.FileInfo(FilePath).Length.ToString())


HTH

Rob
 

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

Forum statistics

Threads
474,039
Messages
2,570,375
Members
47,021
Latest member
AleciaMcMa

Latest Threads

Top