Tech Off Thread

6 posts

Forum Read Only

This forum has been made read only by the site admins. No new threads or comments can be added.

Stopping asp.net setting content-type

Back to Forum: Tech Off
  • User profile image
    stevo_

    Been working on a xml+xslt > xhtml testing solution recently. We noticed that firefox has a problem with reading the aspx pages as xml (despite their markup being good). If we rename the file to .xml (no server side stuff happening) it renders good.

    Its almost as if the xml is being ignored entirely, for example: theres no xml tree rendered, I get the inner content of all the xml elements rendered instead.

    Looking at the generated source (select all and copy to a smart textfield) I can see that firefox is wrapping the xml in basic html tags.

    Hence the reason its rendering like html rather than xml..

    Checking with fiddler, the http requests being sent are specified as text/html. This states that firefox is reading the header over any content in the document.

    However.. if I manually write the content output to be text/xml, it works - but I have to cull the xml header tag out of the source...

    Ok, this may seem somewhat anal.. I've achieved what I wanted. But I don't like the fact that my source code doesn't tell the story properly.. the first tag it starts with is the xsl style sheet href.

    It seems to me that if I can set my content-type to nothing, the browser will detect the content from the first line of the body.

    This is how I want it to work.

  • User profile image
    ZippyV

    Funny, I'm working on the exact same stuff as you at the moment. I just tried the .xml to .aspx extension change and I get the same problem but I was able to solve it. Make sure this is in the first line of your xml document:

    <%@ Page ContentType="text/xml" %><?xml version="1.0" encoding="utf-8" ?>

  • User profile image
    stevo_

    Wow, thats really odd. It works- but you literally do need the <?xml tag to be inline with the page declaration tag...

    Cheers though, thats pretty mad that you were working on the exact same thing. Tongue Out

  • User profile image
    ZippyV

    Have you tried putting the xml declaration on the 2nd line? I wanted it to be 'clean' too but the <@ page thing gets replaced with an empty line and Firefox wants the xml declaration to be on the first.
    Probably yet another error in Firefox that I've encountered in the last week.

  • User profile image
    ZippyV

    Are you able to display the € character on your site?
    I can't display it in IE and now that I changed the extension to aspx it can't display it either in Firefox. Everything is saved as UTF-8 without signature.

  • User profile image
    stevo_

    Works good for me, I'd maybe check to see what content-encoding asp.net is sending the page out as. I've been using fiddler to see whats happening at the http request/response level.

    Edit, also- if I put the xml dec on the second line- firefox isn't happy.

Conversation locked

This conversation has been locked by the site admins. No new comments can be made.