Hi! Patrice,
Thanks for the response. I am using filestream to read the file like
Dim strFilePath As String
Dim strFileName As String
Dim fsFile As FileStream
Dim strFileExtn As String
Dim strMIMEType As String
Dim lnFileSize As Long
strFileName = "XXXX_050601105406_DIA.JPG"
strFilePath = "\\<Network Server Name>\<folder
Name>\XXXX_050601105406_DIA.JPG"
strFileExtn = strFileName.Substring(strFileName.LastIndexOf(".") + 1)
Select Case strFileExtn.ToUpper()
Case "AU", "SND"
strMIMEType = "audio/basic"
Case "WAV"
strMIMEType = "audio/wav"
Case "RA", "RM", "RAM"
strMIMEType = "audio/x-pn-realaudio"
Case "MID", "MIDI"
strMIMEType = "audio/x-midi"
Case "MP3"
strMIMEType = "audio/mp3"
Case "M3U"
strMIMEType = "audio/m3u"
Case "TXT", "TEXT", "VBS", "ASP", "CGI", "PL", "NFO", "ME", "DTD"
strMIMEType = "text/plain"
Case "HTM", "HTML", "HTA", "HTX", "MHT"
strMIMEType = "text/html"
Case "JS"
strMIMEType = "text/javascript"
Case "CSS"
strMIMEType = "text/css"
Case "PDF"
strMIMEType = "application/pdf"
Case "RTF"
strMIMEType = "application/rtf"
Case "XML", "XSL", "XSLT"
strMIMEType = "text/xml"
Case "WPD"
strMIMEType = "application/wordperfect"
Case "WRI"
strMIMEType = "application/mswrite"
Case "XLS", "XLS3", "XLS4", "XLS5", "XLW"
strMIMEType = "application/msexcel"
Case "DOC"
strMIMEType = "application/msword"
Case "PPT", "PPS"
strMIMEType = "application/mspowerpoint"
Case "WML"
strMIMEType = "text/vnd.wap.wml"
Case "WMLS"
strMIMEType = "text/vnd.wap.wmlscript"
Case "WBMP"
strMIMEType = "image/vnd.wap.wbmp"
Case "WMLC"
strMIMEType = "application/vnd.wap.wmlc"
Case "WMLSC"
strMIMEType = "application/vnd.wap.wmlscriptc"
Case "GIF"
strMIMEType = "image/gif"
Case "JPG", "JPE", "JPEG"
strMIMEType = "image/jpeg"
Case "PNG"
strMIMEType = "image/png"
Case "BMP"
strMIMEType = "image/bmp"
Case "TIF", "TIFF"
strMIMEType = "image/tiff"
Case "AI", "EPS", "PS"
strMIMEType = "application/postscript"
Case "ASF"
strMIMEType = "video/x-ms-asf"
Case "AVI"
strMIMEType = "video/avi"
Case "MPG", "MPEG"
strMIMEType = "video/mpeg"
Case "QT", "MOV", "QTVR"
strMIMEType = "video/quicktime"
Case "SWA"
strMIMEType = "application/x-director"
Case "SWF"
strMIMEType = "application/x-shockwave-flash"
Case "ZIP"
strMIMEType = "application/x-zip-compressed"
Case "GZ"
strMIMEType = "application/x-gzip"
Case "RAR"
strMIMEType = "application/x-rar-compressed"
Case "COM", "EXE", "DLL", "OCX"
strMIMEType = "application/octet-stream"
Case Else
strMIMEType = "application/octet-stream"
End Select
Response.Clear()
Response.ContentType = strMIMEType
Response.AddHeader("content-disposition", "attachment;filename=" +
strFileName)
fsFile = New FileStream(strFilePath, FileMode.Open)
lnFileSize = fsFile.Length
Dim getContent(CInt(lnFileSize)) As Byte
fsFile.Read(getContent, 0, CInt(fsFile.Length))
fsFile.Close()
Response.BinaryWrite(getContent)
Response.End()
It's working fine when i am viewing a page without user authentications.
In my project, different user's have username and encrypted passwords. On
valid authentication user is allowed to go into the site. Here the problem
occours when the user is trying to view the files, whereas if user downloads
the file, its downloads properly with the correct file.
Thanks,
Baren