Why save as dialog is displaying twise

V

Vijay Neelam

Hi all,
Dim a As String = Response.ContentType
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/msword"
Response.AddHeader("content-disposition", "attachment;
filename=Document.doc")
Response.Write(strDoc)
Response.ContentType = a
Response.End()

I'm writing this code in ASP.NET I'm getting download dialog box but I'm
getting twise if I clicked on open.

My purpose is I want to download a worddocument from server and also need to
write some string in that document.

Open is only opening MSWord window but not opening document.

Does any one know solution to this problem.. please post

Thank you,
Vijay Neelam
 
H

HD

Dont think things have changed with ASP.NET to that an extent.
What you are trying to do Vijay would only tell the client browser that the
server is pushing data of type word in the response. hence it asks you
whether you would like to save it.
If you want ASP.net to word and write something to the file then you will
have to look into server side code. Create an object of type
word.application and then write to it. Save it n the harddrive and transfer
the script to the relative location of word doc. or save it and then use
binary reading and write the binary info to response post the headers you
were using.

hope i help clear things out,

HD
 
J

Jose Gonzalez

What browser are you using?
this sounds similar to a problem I was having before.
I might be wrong but I think it was an issue in IE 5.x.
 
H

HD

Jose,

The reason its asked atleast once is that .doc is not associated with the
browsers unless you have a plugin when then i think it will ask you once.
The above example would work fine with txt file cause txt files not have any
custom headers and txt files are fine with txt files are client response.
With .doc you have a custom header and he needs to write the .doc file
header in order to populate it.

HD

The problem is because the header is possibly not perfect.
Dont know everything about ASP.NET but
 
V

Vijay Neelam

I followed all suggestion given in link you have mentioned.Even I cleared
Headers , But still I'm getting open dialog twise...

I'm using IE 6.02800.1106

Update Versions:; SP1; Q810847; Q813951; Q813489; Q330994; Q818529; Q822925;
Q828750;

Even I checked all possible combinations in response.header like Filename
and filename
\".

Response.Buffer = True
Response.Clear()
Response.Charset = "UTF-8"
Response.ContentType = "application/msword"
'Response.ContentType = "application/octet-stream"
Response.ClearHeaders()
Rsponse.AddHeader("content-disposition", "attachment;
filename=document.doc")
Response.Write("String")
Response.Flush()
Response.End()
Thank you
Regards
vijay neelam
 

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
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top