ContentType

H

Henrry Pires

Hello to all.

I'm trying to diplay word, exel and pdf documentes inside the ie window.
To show a pdf file i know that i have to set the property ContentType =
"application/pdf". But I was unable to find the value to display exel files.
Does ny one know what correct value to show this kind of values?


Thanks in advance
 
K

Kevin Spencer

application/octet-stream

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 
H

Henrry Pires

It dosn't work. when I put that it try to download the page (my aspx page).
Stange.
 
K

Kevin Spencer

That's right. My apologies. While the content-type is correct for any type
of binary file stream, the file name is not identified, and therefore, the
browser can't identify the file.

The problem here is that the MIME type for an Excel Spreadsheet might or
might not be recognized by the browser. A browser can identify a file type
by either of 2 things: content-type header, and file name. Since the file
has a .aspx extension, the browser can't know what the type is from the
extension.

What I omitted was the Content-Dispostion header, which indicates the name
of the file. The following article details how to do this:

http://www.dotnetspider.com/technology/kbpages/553.aspx

The salient code in the article is as follows:

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "Filename=Requirements.doc" );

Of course, in your case, it would be the file name with an "xls" extension.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
Who is Mighty Abbott?
A twin turret scalawag.
 

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,774
Messages
2,569,598
Members
45,146
Latest member
Vinay KumarNevatia_
Top