ContentType problem - downloading instead of displaying

B

Bryan Glennon

I have an aspx page. If I set the Response.ContentType =
"application/voicexml+xml" then when I load browse to the page it
downloads the file and opens .Net Studio to allow me to edit it. It
should just display in my browser (as it does if I don't set the
ContentType).

I have appropriate MIME types set up in IIS (.vxml -->
application/voicexml+xml).

What am I doing wrong here? And more important, how can I fix it?

TIA,
BG
 
H

Hermit Dave

i think the problem is that the mime type is not associated with your
browser it is rather associated with your vs.net

try looking up the file types under folder options. remove the association
with vs.net and then try.

Hope this helps,

HD
 
M

MSFT

Hi Bryan Glennon,


Thank you for using Microsoft Newsgroup service. Based on your description,
you have an aspx
page which is to show a VXML file for the user to download or open? Also,
you've add the the
mime type in the IIS. However, when you run the page and click the "open"
button on the downdload
dialog, you found that the vxml file was opened in the VS.NET rather than
the tool confitgured in
the Folder options? Please correct me if my understanding of your problem
is not quite accureate.

If my understanding is true, here is some suggestion:

In asp.net, if you want to show a certain type of data to the client and
want it to be display or downloaded,
you can use the following code:

private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
string name = "VXML.vxml"; //VXML.vxml is a vxml file on the server
Response.Clear();
Response.AppendHeader( "content-disposition","attachment; filename=" +
name );
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.ContentType = "application/voicexml+xml";
Response.WriteFile(Server.MapPath(name));
Response.End();

}

In addition to setting the "Response.ContentType", you need also use the
"Response.AppendHeader" or "Response.AddHeader" to
add a header element into the response output stream. And the
"content-disposition" attribute will force the download dialog
to popup. Also, this header element will let the client side to choose the
proper tool to deal with the response output stream(doucment).
For more information about the "Content-Disposition" Header Field, you can
visit the following web link:
http://xml.resource.org/public/rfc/html/rfc2183.html#anchor2


I've tested the code on my side, when didn't add "Response.AppendHeader(
"content-disposition","attachment; filename=" + name )"
the vxml document did will be opended by the VS.NET. If add it, when load
the file in browser, the file will be opened by the tool you specified
in the Folder options's file association. If nothing is specified in the
client side 's file association(with the "vxml), there will popup the
dialog to let you choose a tool or webservice to open it.


Please try out the preceding suggestion to see whether it helps. Also if
you have any questions on it, please feel free to let me know.


Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Steven Cheng[MSFT]

Hi Bryan Glennon,


Have you had a chance to try my suggestion or is your problem resolved ?
Please let me know if you need any help.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
B

Bryan Glennon

Steven -
I did try it, and it works as you describe, but I need the vxml to
open in IE, and I can't make that happen.

(Sorry for taking so long to get back to you, but I was out of town
for a while)

Thanks for the help,
Bryan
 
S

Steven Cheng[MSFT]

Hi Bryan,

Thank you for the response. Based on your description in the last reply.
You'd like the VXML file to be displayed in IE, yes?
I think if you just want to display the vxml file in IE(without popup the
file download dialog) when the browser navigate to it, you can just set the
ContentType as "text/xml", then the vxml will be displayed in IE as a xml
document. For example:
Response.ContentType = "text/xml";

However, if you do need to set the ContentType as
"application/voicexml+xml", then, this is a particular document type that
the IE doesn't support by default. So if the response returned such
ContentType, the client will search for the most proper tools to open it.
Such as VS.NET or other ones(of course, this can be specified in client),
but the server side can't specify how the document is opened in client.

If you have any questions on it, please feel free to let me know.
Happy New year!

Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
B

Bryan Glennon

Steven -
I'm not sure there is a way around this. The basic issue is that for
execution on our voice platform, they type should be set to
application/voicexml+xml. But when I'm debugging, I like to be able to
see the vxml in my browser rather than having to listen to it being
processed on the voice platform.

Thanks again for the help, and have a great new year.

-Bryan
 
S

Steven Cheng[MSFT]

Hi Bryan,

Thanks for your response. Yes, sometimes we need different display style in
debuging time and deplyment time. However, in our issue, since how the
document displayed in the browser depends on the ContentType, we'd have to
use different ContentType if at debug and deploy time if we want the
different style it shows. Maybe you can workaround this way if you think it
possbile. Any way, thanks again for your wish.

If you have any questions, please feel free to let me know. Have a greate
New year, too.


Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 

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,776
Messages
2,569,603
Members
45,190
Latest member
ClayE7480

Latest Threads

Top