I have the following code
If dr.Read() Then
If CStr(dr("doc_name")).ToUpper.EndsWith(".PDF") Then
Response.ContentType = "application/pdf"
ElseIf CStr(dr("doc_name")).EndsWith(".htm") Or CStr(dr("doc_name")).EndsWith(".html") Then
Response.ContentType = "text/html"
ElseIf CStr(dr("doc_name")).EndsWith(".tif") Then
Response.ContentType = "image/tiff"
ElseIf CStr(dr("doc_name")).EndsWith(".jpeg") Or CStr(dr("doc_name")).EndsWith(".jpg") Then
Response.ContentType = "image/jpeg"
Else
Response.ContentType = "application/msword"
End If
Response.Buffer = True
...
Go to the complete details ...