Thanks for the response, Dauhee.
The code snipet for the adding the content type and header did not force the file to be opened outside the browser in its native program in my testing.
My test code:
Response.Clear()
Response.ContentType = "Application/x-msexcel"
Response.AddHeader("Conten
Response.WriteFile("C:\Doc
Response.Flush()
Response.End()
I am I missing something?
Thanks.
Main Topics
Browse All Topics





by: DauheePosted on 2008-06-21 at 06:50:33ID: 21837567
Would you consider going about it in a different way. Rather than serving up directly, write the file out the the browser using an asp.net page (or equivalent). This way as new PCs come online you won't have to go changing how files are handled:
t-Disposit ion", "attachment; filename=" & IO.Path.GetFileName(strFil eName).Rep lace(" ", "_")) Name)
Val strFileName As String) As String
leName).To Upper
ntentHeade r) Then
Response.Clear()
Response.ContentType = strContentHeader
Response.AddHeader("Conten
Response.WriteFile(strFile
Response.Flush()
Response.End()
Option #2: if you really don't want to do tha and proceed to change the PCs settings - then dump out the registry before the change. then dump out afterwards. do a comparison of the two files and check what has changed (can use kdiff application or equivalent). then you can put the modified registry string into a .reg file. From there you could get network admin to put the reg file into users logon batch script
To set the relevant contenttype (option #1) such as:
Public Function GetContentHeaderForFile(By
Dim strExtension As String = String.Empty
Dim strContentHeader As String = String.Empty
Try
strExtension = IO.Path.GetExtension(strFi
Select Case strExtension
Case ".PDF"
strContentHeader = "Application/pdf"
Case ".GIF"
strContentHeader = "image/GIF"
Case ".JPEG"
strContentHeader = "image/JPEG"
Case ".HTML"
strContentHeader = "text/HTML"
Case ".DOC"
strContentHeader = "Application/msword"
Case ".XLS"
strContentHeader = " application/ms-excel" '"Application/x-msexcel"
Case ".CSV"
strContentHeader = "text/csv"
Case ".XML"
strContentHeader = "text/xml"
End Select
Catch
End Try
If String.IsNullOrEmpty(strCo
'default to text if none found (may be ".TXT", ".LOG", ".SQL" etc)
strContentHeader = "text/plain"
End If
Return strContentHeader
End Function