I have a IIS web site that works fine on one server but not another. I
do not know if the problem is an IIS setting or something else so I
will try to include as much detail as I have figured out so far.

Several web pages allow the user to download PDF files to be viewed or
saved locally on the user's machine, not in the browser. Those web
pages all redirect to a single ASP page with QueryString parameters
identifying the relative path to the desired file on a remote server.

The redirect URL would be something like:

download.asp?Src=Statements\2006\01\123456789

My download.asp code looks something like this:

=================================================
Dim strSourceName
Dim objDocServer

' Retrieve the path to the desired document
strSourceName = Request.QueryString("Src")

' Call remote COM+ application and retrieve document as binary stream
Set objDocServer = Server.CreateObject("DocumentServer.Application")
Set objDocServer.Document = objDocServer.getDocument(strSourceName)

With Response
.Buffer = True
.Clear
.ContentType = "application/pdf"
.AddHeader "content-disposition", "attachment; filename=test.pdf;"
.BinaryWrite(objDocServer.Document)
End With
=================================================

When I try to download a file, the browser shows the File Download
dialog asking me to Open or Save the file but it shows the File name as
"123456789" rather than "test.pdf". It also shows a blank value for the
File type. Whether I choose Open or Save the same error appears:

Internet Explorer cannot download 123456789 from <server>.
Internet Explorer was not able to open this site. The requested site is
either unavailable or cannot be found. Please try again later.

If I comment out the AddHeader line, the File type shows correctly as
Adobe Acrobat Document.

If I change the AddHeader to inline rather than attachment, I see the
binary data in the browser.

This exact code works fine on another server and I have no idea why it
will not work on this new server. What I find interesting is that the
download wants to name the file as 123456789 which comes from a part of
a QueryString value and nowhere else. Could this have something to do
with the "\" characters in the QueryString being confused as path
delimiters by IIS/ASP?

Any ideas or help are appreciated!

Michael

Re: AddHeader Content-Disposition Has no effect by Patrice

Patrice
Thu Jul 06 06:24:15 CDT 2006

Also what if you try to remove the ";" after the filename in the content
disposition header ?

--
Patrice

<Michael@MichaelLevy.net> a écrit dans le message de news:
1152146313.586854.94120@75g2000cwc.googlegroups.com...
>I have a IIS web site that works fine on one server but not another. I
> do not know if the problem is an IIS setting or something else so I
> will try to include as much detail as I have figured out so far.
>
> Several web pages allow the user to download PDF files to be viewed or
> saved locally on the user's machine, not in the browser. Those web
> pages all redirect to a single ASP page with QueryString parameters
> identifying the relative path to the desired file on a remote server.
>
> The redirect URL would be something like:
>
> download.asp?Src=Statements\2006\01\123456789
>
> My download.asp code looks something like this:
>
> =================================================
> Dim strSourceName
> Dim objDocServer
>
> ' Retrieve the path to the desired document
> strSourceName = Request.QueryString("Src")
>
> ' Call remote COM+ application and retrieve document as binary stream
> Set objDocServer = Server.CreateObject("DocumentServer.Application")
> Set objDocServer.Document = objDocServer.getDocument(strSourceName)
>
> With Response
> .Buffer = True
> .Clear
> .ContentType = "application/pdf"
> .AddHeader "content-disposition", "attachment; filename=test.pdf;"
> .BinaryWrite(objDocServer.Document)
> End With
> =================================================
>
> When I try to download a file, the browser shows the File Download
> dialog asking me to Open or Save the file but it shows the File name as
> "123456789" rather than "test.pdf". It also shows a blank value for the
> File type. Whether I choose Open or Save the same error appears:
>
> Internet Explorer cannot download 123456789 from <server>.
> Internet Explorer was not able to open this site. The requested site is
> either unavailable or cannot be found. Please try again later.
>
> If I comment out the AddHeader line, the File type shows correctly as
> Adobe Acrobat Document.
>
> If I change the AddHeader to inline rather than attachment, I see the
> binary data in the browser.
>
> This exact code works fine on another server and I have no idea why it
> will not work on this new server. What I find interesting is that the
> download wants to name the file as 123456789 which comes from a part of
> a QueryString value and nowhere else. Could this have something to do
> with the "\" characters in the QueryString being confused as path
> delimiters by IIS/ASP?
>
> Any ideas or help are appreciated!
>
> Michael
>



Re: AddHeader Content-Disposition Has no effect by Michael

Michael
Thu Jul 06 11:11:33 CDT 2006


Patrice wrote:
> Also what if you try to remove the ";" after the filename in the content
> disposition header ?
>

That makes no difference. I originally did not have the semi-colon but
added it after seeing such in an example. Either way, it works on one
environment but not another.


Re: AddHeader Content-Disposition Has no effect by Anthony

Anthony
Thu Jul 06 11:56:03 CDT 2006


<Michael@MichaelLevy.net> wrote in message
news:1152202290.135060.77490@75g2000cwc.googlegroups.com...
>
> Patrice wrote:
> > Also what if you try to remove the ";" after the filename in the content
> > disposition header ?
> >
>
> That makes no difference. I originally did not have the semi-colon but
> added it after seeing such in an example. Either way, it works on one
> environment but not another.
>

Have you tried using a URL that doesn't have \ in the query string?
Have you tried escaping the \ as %5C ?
Are the two servers on the same OS and at the same service pack?
Have checked that are no additional headers being added by the page or
folder properties?




Re: AddHeader Content-Disposition Has no effect by Patrice

Patrice
Thu Jul 06 12:10:05 CDT 2006

What if you do simple test without anything on the query string. Something
as simple as :

With Response
.Buffer = True
.Clear
.ContentType = "text/plain"
.AddHeader "content-disposition", "attachment; filename=test.txt"
.Write("Hello world")
End With

If it works wihtout but don"t with, then it's definitively the querystring.
If the qs make this fails, try with and without path chars (or just try
right now to encode as sugested by Anthony). With those combinations, you
should able to find out what causes the problem.

--
Patrice

<Michael@MichaelLevy.net> a écrit dans le message de news:
1152202290.135060.77490@75g2000cwc.googlegroups.com...
>
> Patrice wrote:
>> Also what if you try to remove the ";" after the filename in the content
>> disposition header ?
>>
>
> That makes no difference. I originally did not have the semi-colon but
> added it after seeing such in an example. Either way, it works on one
> environment but not another.
>



Re: AddHeader Content-Disposition Has no effect by Michael

Michael
Thu Jul 06 13:18:04 CDT 2006


Anthony Jones wrote:
> <Michael@MichaelLevy.net> wrote in message
> news:1152202290.135060.77490@75g2000cwc.googlegroups.com...
>
> Have you tried using a URL that doesn't have \ in the query string?
> Have you tried escaping the \ as %5C ?
> Are the two servers on the same OS and at the same service pack?
> Have checked that are no additional headers being added by the page or
> folder properties?

Both servers are running Windows 2000 Advanced Server / Serivce Pack 4

I don't know what you mean by "headers being added by the page or
folder properties". Can you explain what this is and how I would check?

I tried another test case with no query string and get the same
results. The complete code of my new download.asp follows. It merely
writes out a local pdf file as a binary stream.

<%

Const adTypeBinary = 1
Dim strFilePath

strFilePath = Server.MapPath("my.pdf") 'This is the path to the file on
disk.

Set objStream = Server.CreateObject("ADODB.Stream")
objStream.Open
objStream.Type = adTypeBinary
objStream.LoadFromFile strFilePath

With Response

'Build the Response header
.Buffer = True
.Clear
.ContentType = "application/pdf"
.AddHeader "content-disposition", "filename=my.pdf;"

'Write the binary stream to the browser
.BinaryWrite objStream.Read
.End

End With

objStream.Close
Set objStream = Nothing

%>


Re: AddHeader Content-Disposition Has no effect by Michael

Michael
Thu Jul 06 13:22:19 CDT 2006

Let me clarify when I said I get the same results without the query
string. Now the download wants to name the file "download.asp" but I
get the same error message when I click Open or Save.


Re: AddHeader Content-Disposition Has no effect by Michael

Michael
Thu Jul 06 17:30:34 CDT 2006


Patrice wrote:
> What if you do simple test without anything on the query string. Something
> as simple as :
>
> With Response
> .Buffer = True
> .Clear
> .ContentType = "text/plain"
> .AddHeader "content-disposition", "attachment; filename=test.txt"
> .Write("Hello world")
> End With
>
> If it works wihtout but don"t with, then it's definitively the querystring.
> If the qs make this fails, try with and without path chars (or just try
> right now to encode as sugested by Anthony). With those combinations, you
> should able to find out what causes the problem.
>
> --
> Patrice
>

Hi Patrice,

I just tried that and I still get the same results. I saved that code
in a file named test2.asp. When I go to that ASP page, it displays the
File Download dialog indicating it is trying to download a file named
test2.asp with no file type specified and I get the same error message
as always.

I am sure this is not a code problem but something on the server
settings.

Michael


Re: AddHeader Content-Disposition Has no effect by Patrice

Patrice
Fri Jul 07 02:25:42 CDT 2006

Do you have something special in the IIS log for those requests ? Being able
to see the whole server response using XMLHTTP or a network tool may also
help.

Do you have a firewall ?

Good luck.
--
Patrice

"Michael" <Michael@MichaelLevy.net> a écrit dans le message de news:
1152225034.693428.210110@m73g2000cwd.googlegroups.com...
>
> Patrice wrote:
>> What if you do simple test without anything on the query string.
>> Something
>> as simple as :
>>
>> With Response
>> .Buffer = True
>> .Clear
>> .ContentType = "text/plain"
>> .AddHeader "content-disposition", "attachment; filename=test.txt"
>> .Write("Hello world")
>> End With
>>
>> If it works wihtout but don"t with, then it's definitively the
>> querystring.
>> If the qs make this fails, try with and without path chars (or just try
>> right now to encode as sugested by Anthony). With those combinations, you
>> should able to find out what causes the problem.
>>
>> --
>> Patrice
>>
>
> Hi Patrice,
>
> I just tried that and I still get the same results. I saved that code
> in a file named test2.asp. When I go to that ASP page, it displays the
> File Download dialog indicating it is trying to download a file named
> test2.asp with no file type specified and I get the same error message
> as always.
>
> I am sure this is not a code problem but something on the server
> settings.
>
> Michael
>



Re: AddHeader Content-Disposition Has no effect by Atul

Atul
Fri Jul 07 04:54:15 CDT 2006

Check out the IEWatch tool. It gives you plenty of information about
the Request and Response as handled by the IE Web Browser. Not sure if
something similar is availble for other browsers but this will be
surely helpful.
Here's the URL

http://www.iewatch.com/downloads.aspx

Unfortunately it's not a freeware. :)

Patrice wrote:
> Do you have something special in the IIS log for those requests ? Being a=
ble
> to see the whole server response using XMLHTTP or a network tool may also
> help.
>
> Do you have a firewall ?
>
> Good luck.
> --
> Patrice
>
> "Michael" <Michael@MichaelLevy.net> a =E9crit dans le message de news:
> 1152225034.693428.210110@m73g2000cwd.googlegroups.com...
> >
> > Patrice wrote:
> >> What if you do simple test without anything on the query string.
> >> Something
> >> as simple as :
> >>
> >> With Response
> >> .Buffer =3D True
> >> .Clear
> >> .ContentType =3D "text/plain"
> >> .AddHeader "content-disposition", "attachment; filename=3Dtest.txt"
> >> .Write("Hello world")
> >> End With
> >>
> >> If it works wihtout but don"t with, then it's definitively the
> >> querystring.
> >> If the qs make this fails, try with and without path chars (or just try
> >> right now to encode as sugested by Anthony). With those combinations, =
you
> >> should able to find out what causes the problem.
> >>
> >> --
> >> Patrice
> >>
> >
> > Hi Patrice,
> >
> > I just tried that and I still get the same results. I saved that code
> > in a file named test2.asp. When I go to that ASP page, it displays the
> > File Download dialog indicating it is trying to download a file named
> > test2.asp with no file type specified and I get the same error message
> > as always.
> >
> > I am sure this is not a code problem but something on the server
> > settings.
> >
> > Michael
> >


Re: AddHeader Content-Disposition Has no effect by Anthony

Anthony
Sat Jul 08 04:06:13 CDT 2006


"Michael" <Michael@MichaelLevy.net> wrote in message
news:1152225034.693428.210110@m73g2000cwd.googlegroups.com...
>
> Patrice wrote:
> > What if you do simple test without anything on the query string.
Something
> > as simple as :
> >
> > With Response
> > .Buffer = True
> > .Clear
> > .ContentType = "text/plain"
> > .AddHeader "content-disposition", "attachment; filename=test.txt"
> > .Write("Hello world")
> > End With
> >
> > If it works wihtout but don"t with, then it's definitively the
querystring.
> > If the qs make this fails, try with and without path chars (or just try
> > right now to encode as sugested by Anthony). With those combinations,
you
> > should able to find out what causes the problem.
> >
> > --
> > Patrice
> >
>
> Hi Patrice,
>
> I just tried that and I still get the same results. I saved that code
> in a file named test2.asp. When I go to that ASP page, it displays the
> File Download dialog indicating it is trying to download a file named
> test2.asp with no file type specified and I get the same error message
> as always.
>
> I am sure this is not a code problem but something on the server
> settings.
>
> Michael
>

As Patrice has pointed out the next step is to examine/compare exactly what
the servers are sending to the client.

By far the best free tool for this job is:-

http://www.fiddlertool.com/fiddler/

Anthony.