2

This is the same question as this but I'm looking for a classic ASP solution.

I have a third party control to provide secure downloads but it expects you to provide the response.contenttype value. I'm trying to have the browser prompt with the following:

Response.AddHeader "Content-Disposition", "attachment;filename=""" & strFileName & """"

However Safari doesn't like any of the suggested content types (does odd things with the file name - like add ".exe" to the end).

  • application/x-msdownload
  • application/force-download

So I'd either like to query IIS for the correct content type or find a generic content type that would let the browser figure it out in a somewhat reliable fashion.

Community
  • 1
  • 1
William Jens
  • 422
  • 2
  • 6
  • 15

2 Answers2

0

Typically the mimemap being used by the site is stored at server level and you can get into permission issues trying to read it. It requires some nasty ADSI code.

Have you tried the standard application/octet-stream as a mime type?

AnthonyWJones
  • 187,081
  • 35
  • 232
  • 306
  • Sorry for the late accept/edit. Turns out the control had a function to make a best guess at the mime type. The mime type mentioned didn't always produce ideal results across all browsers/platforms. – William Jens Aug 02 '09 at 00:51
0

From Reading the server mimemap:

Public Function GetMimeType(ByVal Extension)
   Dim oMimeMap
   Dim vntMimeType
   Dim avntMap()

   Set oMimeMap = GetObject("IIS://LocalHost/MimeMap")

   If Left(Extension, 1) <> "." Then Extension = "." & Extension

    avntMap() = oMimeMap.MimeMap

    For Each vntMimeType In avntMap
        If vntMimeType.Extension = Extension Then
            GetMimeType = vntMimeType.MimeType
            Exit For
        End If
    Next

    If GetMimeType = "" Then GetMimeType = "application/octet-stream"
End Function

Note: the code calling GetObject is required to be an Operator in WWW Service Master properties.

Ian Boyd
  • 246,734
  • 253
  • 869
  • 1,219