Response.AddHeader("Content-Disposition"....

Discussion in 'ASP .Net' started by Trapulo, Sep 7, 2006.

  1. Trapulo

    Trapulo Guest

    I've this statement in my output's creation:

    Response.Clear()

    Response.ContentType = "application/vnd.google-earth.kml+xml kml"

    Response.AddHeader("Content-Disposition", "inline; filename=Log_" &
    activityLogID & ".kml")

    The strage is that on my development server all works (IE try to open the
    file with GE, and if I force it to save the file when I click on the link,
    it prompts for "Log_....." file name). But on production server, IE doesn't
    recognize MIME type, and if I force it to save the file, it prompts for the
    original aspx's file name.
    Firefox works well on all two servers. Where is the error?

    thanks
    Trapulo, Sep 7, 2006
    #1
    1. Advertising

  2. Trapulo

    Trapulo Guest

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hello Trapulo,
    >
    > From your description, you're using ASP.NET page to flush out some google
    > earth map file and let the client-side choose the google earth, however,
    > you found this works when running the application on development server
    > but
    > not work when running on a production server ,correct?


    yes

    > As for the different behavior, are you getting them on the same client
    > machine when visiting the server page or just test locally on each server?
    > I would recommend you try different remote client machine to see whether
    > you'll get different behavior.


    I try from the same machine, that is also the development server. I've also
    tried from other machines, but only calling the production server, and I
    have the same behavior.

    > Based on my experience, the client-side browser's behavior against
    > handling
    > different mime-type is depend on its internal implementation. For IE, you
    > can have a look at the following msdn article:
    >
    > #MIME Type Detection in Internet Explorer
    > http://msdn.microsoft.com/workshop/networking/moniker/overview/appendix_a.as
    > p?frame=true


    I think the problem can be here:
    "If a positive match is found (one of the hard-coded tests succeeded), this
    MIME type is immediately returned as the final determination, overriding the
    server-provided MIME type (this type of behavior is necessary to identify a
    ..gif file being sent as text/html). During scanning, it is determined if the
    buffer is predominantly text or binary."

    maybe IE scan content, and see that it is an xml file. So it shows it as
    xml, ignoring mime directive. If this can explain the problem (and then I
    don't know how to solve it because this is xml, but IE may open with right
    viewer), this doesn't explain why calling the page on the production server
    works.

    > And if the problem is specific to server, you can check the registered
    > mime-type in IIS 6's service manager(see my attached screenshot in this
    > message). You need to select the topest(machine) node in IIS manager and
    > right click to choose "properties" menu.


    Yes, I know this. But if I am generating the kml format from aspx, I think
    that MIME types are unuseful, aren't them? In fact, either on my development
    server I cannot find a setting related to this format. The only difference
    between two servers is that the development one has google earth installed,
    but I think it's strange it can change IIS behavor..

    > and as for the filename problem, what's the behevior if you choose the
    > code
    > as below:
    >
    > ========================
    > Response.ClearHeaders();
    > Response.ClearContent();
    >
    > Response.ContentType = "application/vnd.google-earth.kml+xml kml"
    >
    > Response.AddHeader("Content-Disposition", "attachment; filename=Log_" &
    > activityLogID & ".kml")
    >
    > ===================
    >
    > this will always prompt for file open or save.


    I try this, however my requirenment is to open direct the file and not to
    save it. However, it can be an acceptable tradeoff if this can work with IE
    also, and not with firefox.

    thanks
    Trapulo, Sep 8, 2006
    #2
    1. Advertising

  3. Thanks for your reply Trapulo,

    If you get the different results on the same client machie against
    differetn target server. It is still likely the response stream contains
    different content/headers. As for those IIS server mime-type setting,
    they're actually read from the server machine's registry. Also, you
    mentioned that the difference between the two servers is that development
    server has google earch installed while the deployment machine not, you can
    check whether the mime-type lists on the two machines also vary.

    For general testing, I think you can try put a static kml file in IIS
    virual diretory and use browser to navigate to it to see how the client
    browser process it. You can also use some network trace tools to capture
    the http response stream of the two different response(correct and
    incorrect) to see what's the difference in the raw response.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Sep 11, 2006
    #3
  4. Trapulo

    Trapulo Guest

    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Thanks for your reply Trapulo,
    >
    > If you get the different results on the same client machie against
    > differetn target server. It is still likely the response stream contains
    > different content/headers. As for those IIS server mime-type setting,
    > they're actually read from the server machine's registry. Also, you
    > mentioned that the difference between the two servers is that development
    > server has google earch installed while the deployment machine not, you
    > can
    > check whether the mime-type lists on the two machines also vary.
    >


    I tried to find some specific settings on my development server, but it
    seems that GE has not defined any setting (and, in fact, it seems
    reasonable: it's very strange that it can update IIS settings..).

    > For general testing, I think you can try put a static kml file in IIS
    > virual diretory and use browser to navigate to it to see how the client
    > browser process it.


    how can this work? If the two servers haven't any kml related mime setting,
    IIS cannot stream any header..

    You can also use some network trace tools to capture
    > the http response stream of the two different response(correct and
    > incorrect) to see what's the difference in the raw response.


    Can you suggest any simple tool I can use? I haven't it and I don't know
    what can I use

    However, I've checked that with "attachment" instead of "inline" in
    content.disposition (as you suggested), IE starts google earth and shows the
    file if I select "open" when it asks if open or save the file. It's a
    workaround and it's not the real solution, but it's still a step away.

    thanks
    Trapulo, Sep 13, 2006
    #4
  5. Thanks for your reply Trapulo,

    For your questions in the last reply:


    I tried to find some specific settings on my development server, but it
    seems that GE has not defined any setting (and, in fact, it seems
    reasonable: it's very strange that it can update IIS settings..).
    ==================================
    Yes, I agree that GE won't add any particular settings on the server.
    However, I think it may register the mine-type in registery(whch will
    display in the mime type list). Is this the difference between the two
    servers?



    how can this work? If the two servers haven't any kml related mime setting,
    IIS cannot stream any header..
    ========================================
    due to my limit experience with IIS, I can not gurantee the exact behavior.
    However, the mime-type list you see in the IIS management console's root
    node will affect the response content if the document extension is matching
    one of the mime-type.



    Can you suggest any simple tool I can use? I haven't it and I don't know
    what can I use
    =======================================
    I usually use the trace utility in Soap Toolkit 3.0 to capture http
    request/response messages, you can find it in the following location:

    #SOAP Toolkit 3.0
    http://www.microsoft.com/downloads/details.aspx?FamilyId=C943C0DD-CEEC-4088-
    9753-86F052EC8450&displaylang=en

    Many guys like using Fiddler to debug IE or related issue, it can also
    capture http messages process by IE:

    #Http Debugging with Fiddler
    http://blogs.msdn.com/ie/archive/2005/01/28/362511.aspx

    Hope this helps also.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Sep 15, 2006
    #5
  6. Trapulo

    Trapulo Guest

    "Steven Cheng[MSFT]" <> wrote in message
    news:dQ8p0%...
    > Thanks for your reply Trapulo,
    >
    > For your questions in the last reply:
    >
    > I tried to find some specific settings on my development server, but it
    > seems that GE has not defined any setting (and, in fact, it seems
    > reasonable: it's very strange that it can update IIS settings..).
    > ==================================
    > Yes, I agree that GE won't add any particular settings on the server.
    > However, I think it may register the mine-type in registery(whch will
    > display in the mime type list). Is this the difference between the two
    > servers?


    I cannot find any difference. However, I also know that if I override with
    response.ContentType the default mime type from aspx, IIS will stream data
    with my mime type, and it will not use registry settings..

    > how can this work? If the two servers haven't any kml related mime
    > setting,
    > IIS cannot stream any header..
    > ========================================
    > due to my limit experience with IIS, I can not gurantee the exact
    > behavior.
    > However, the mime-type list you see in the IIS management console's root
    > node will affect the response content if the document extension is
    > matching
    > one of the mime-type.


    yes. But I'm streaming data from an aspx file, so IIS cannot work with
    extension to set kml mime type. It uses aspx extension to start ASP.NET, the
    I can set the mime streamed to the client..

    > Can you suggest any simple tool I can use? I haven't it and I don't know
    > what can I use
    > =======================================
    > I usually use the trace utility in Soap Toolkit 3.0 to capture http
    > request/response messages, you can find it in the following location:


    I find this tool that is very simple and quick to use:
    http://www.initworld.com/mozdev/livehttpheaders

    Results:

    This is from production server:
    HTTP/1.x 200 OK
    Cache-Control: private
    Date: Fri, 15 Sep 2006 09:32:42 GMT
    Content-Type: application/vnd.google-earth.kml+xml kml; charset=utf-8
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    content-disposition: attachment; filename=Localizzazione.kml
    Content-Encoding: gzip
    Vary: Accept-Encoding
    Transfer-Encoding: chunked

    This is from my dev envonment:
    HTTP/1.x 200 OK
    Server: ASP.NET Development Server/8.0.0.0
    Date: Fri, 15 Sep 2006 09:35:36 GMT
    X-AspNet-Version: 2.0.50727
    content-disposition: attachment; filename=Localizzazione.kml
    Cache-Control: private
    Content-Type: application/vnd.google-earth.kml+xml kml; charset=utf-8
    Content-Length: 1001
    Connection: Close

    This is from my development server, using IIS:
    HTTP/1.x 200 OK
    Date: Fri, 15 Sep 2006 09:37:58 GMT
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    content-disposition: attachment; filename=Localizzazione.kml
    Cache-Control: private
    Content-Type: application/vnd.google-earth.kml+xml kml; charset=utf-8
    Content-Length: 969

    And this is an example (from dev IIS) if I restore the content disposition
    value to inline:
    HTTP/1.x 200 OK
    Date: Fri, 15 Sep 2006 09:42:14 GMT
    Server: Microsoft-IIS/6.0
    X-Powered-By: ASP.NET
    X-AspNet-Version: 2.0.50727
    content-disposition: inline; filename=Localizzazione.kml
    Cache-Control: private
    Content-Type: application/vnd.google-earth.kml+xml kml; charset=utf-8
    Content-Length: 969

    I cannot find any interesting difference.
    From dev server, IE open GE. From production, it still shows data as
    standard xml in IE itself :(((
    Trapulo, Sep 15, 2006
    #6
  7. Hi Trapulo,

    Thanks for your followup.

    This does sound a bit strange though we can get that install the GE on the
    server will make the things work, yes?

    Anyway, I'll ask some other IIS or ASP.NET engineers to see whether they
    have any ideas on this. I'll update you if I get any further information on
    this.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Sep 19, 2006
    #7
  8. Hi Trapulo,

    Just post this message you inform you that I'm still waiting for some
    information from other product team engineer. I'll update you as soon as I
    get any new feedback.

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Sep 21, 2006
    #8
  9. Trapulo

    Trapulo Guest

    Thank you.

    Hope they can help us.


    "Steven Cheng[MSFT]" <> wrote in message
    news:p...
    > Hi Trapulo,
    >
    > Just post this message you inform you that I'm still waiting for some
    > information from other product team engineer. I'll update you as soon as I
    > get any new feedback.
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    Trapulo, Sep 21, 2006
    #9
  10. Hi Trapulo,

    Sorry for keep you waiting. I've just got some further feedback from some
    other product team engineer. However, they also think this could be some
    mime-type settnig that Google earch will register it on the machine when
    being installed. Here is the original message from some IIS experts:

    =====================
    it sounds as if Google Earth is adding a file extension assocation to the
    client and then mapping the MIME type to that file extenstion and therefore
    Google Earth

    when receiving a response IE will refer to this list to determine if the
    content needs to be passed to another application

    you can check the file assocations through Windows Explorer in the Tools,
    Folder Options, File Types menu

    it looks as if the MIME type to file extension mappings are stored in the
    registry
    http://support.microsoft.com/kb/302002/en-us

    you should therefore be able to search the registry for
    application/vnd.google-earth.kml which should link to a file extension and
    then confirm that this file extension is mpaped to Google Earth

    not sure how you would override this though as you are using Google Earh
    MIME type which would reasonably be expected to link to Google Earth
    ======================

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Sep 25, 2006
    #10
  11. Trapulo

    Trapulo Guest

    Hello again Steven,
    in fact I found that I have a ".kml" key in the registry of development
    server. However, I've tried to create it on production server also, then I
    restarted IIS, but it's still the same behavior :(

    I also found a key in
    HKEY_CLASSES_ROOT\Mime\Database\Content
    Type\application/vnd.google-earth.kml+xml
    I exported it and imported in production server, restarted IIS, but still
    same.

    It seems that IE WANTS to open the kml as an XML, despite of all other MIME
    commands... :(


    "Steven Cheng[MSFT]" <> wrote in message
    news:...
    > Hi Trapulo,
    >
    > Sorry for keep you waiting. I've just got some further feedback from some
    > other product team engineer. However, they also think this could be some
    > mime-type settnig that Google earch will register it on the machine when
    > being installed. Here is the original message from some IIS experts:
    >
    > =====================
    > it sounds as if Google Earth is adding a file extension assocation to the
    > client and then mapping the MIME type to that file extenstion and
    > therefore
    > Google Earth
    >
    > when receiving a response IE will refer to this list to determine if the
    > content needs to be passed to another application
    >
    > you can check the file assocations through Windows Explorer in the Tools,
    > Folder Options, File Types menu
    >
    > it looks as if the MIME type to file extension mappings are stored in the
    > registry
    > http://support.microsoft.com/kb/302002/en-us
    >
    > you should therefore be able to search the registry for
    > application/vnd.google-earth.kml which should link to a file extension and
    > then confirm that this file extension is mpaped to Google Earth
    >
    > not sure how you would override this though as you are using Google Earh
    > MIME type which would reasonably be expected to link to Google Earth
    > ======================
    >
    > Sincerely,
    >
    > Steven Cheng
    >
    > Microsoft MSDN Online Support Lead
    >
    >
    >
    > This posting is provided "AS IS" with no warranties, and confers no
    > rights.
    >
    >
    Trapulo, Sep 25, 2006
    #11
  12. Thanks for your reply Trapulo,

    That does be abit strange. So currently you can only install Google Earth
    on the server machine to make it work but haven't any other means to
    manually duplicate the configuration Google Earch does? Can you confirm
    the behavior on some other test server? If this does be a common issue, I
    would suggest you consider contact CSS for further troubleshooting on this.
    So far what I can get are limited to the client-side file type mappings
    and the server-side mime-type mappings.


    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead


    This posting is provided "AS IS" with no warranties, and confers no rights.
    Steven Cheng[MSFT], Sep 27, 2006
    #12
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. S.Kartikeyan

    Response.AddHeader content-disposition

    S.Kartikeyan, Feb 6, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    3,959
    S.Kartikeyan
    Feb 6, 2004
  2. S.Kartikeyan
    Replies:
    0
    Views:
    2,786
    S.Kartikeyan
    Mar 1, 2004
  3. Ed
    Replies:
    10
    Views:
    45,855
    alok000707
    Jul 13, 2010
  4. Jawahar Rajan
    Replies:
    1
    Views:
    133
    Bite My Bubbles
    Aug 29, 2003
  5. Replies:
    10
    Views:
    394
    Anthony Jones
    Jul 8, 2006
Loading...

Share This Page