Advertisement

05.13.2008 at 05:04PM PDT, ID: 23399861
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

8.0

Stream a file on the internal network over the web

Asked by krisred in MS SQL Server, Programming for ASP.NET

ok,

I have a domain environment
Server1 is on the domain
Server2 is a webserver and is not part of the domain - is hosting the live website


Server1  has a folder called data which is shared
\\Server1\Data
WebUser has read and list permissions set on this folder

On webserver I have a vb.net application, that streams the files to download
I have setup a user called WebUser on the domain and the webserver with the same password and set it to impersonate user in web.config file

So when I try to stream file over the web, I can't ????
\\Server1\Data\file.pdf

However when I try to launch the the unc path in the webserver, it works

Please help - ??
sGetFile = \\Server1\Data\File.pdf

here is the code used to stream
Dim fs As New FileStream(sGetFile, FileMode.OpenOrCreate, FileAccess.Read)
                  Dim MyData(fs.Length) As Byte
                   
                  fs.Read(MyData, 0, fs.Length)
                  Response.Buffer = True
                  Response.Clear()

                  'Response.ContentType = "application/pdf"
                  Dim sFileType As String = Right(sFile, (Len(sFile) - InStrRev(sFile, ".")))

                  Select Case LCase(sFileType)
                        Case "pdf"
                              Response.ContentType = ("application/pdf")
                        Case "doc"
                              Response.ContentType = ("application/msword")
                        Case "xls"
                              Response.ContentType = ("application/x-excel")
                        Case "pff"
                              Response.ContentType = ("application/ms-powerpoint")
                        Case "zip"
                              Response.ContentType = ("application/zip")
                        Case "tif"
                              Response.ContentType = ("image/tiff")
                        Case "gif"
                              Response.ContentType = ("image/gif")
                        Case "jpg", "jpeg"
                              Response.ContentType = ("image/jpeg")
                        Case "rtf"
                              Response.ContentType = ("image/rtf")
                        Case "txt"
                              Response.ContentType = ("text/plain")
                        Case Else
                              Response.ContentType = ("text/html")
                              'Response.Write("Error: Could not locate file for download: " & sFile)
                              'Response.End()
                  End Select

                  ' Set headers
                  'If sFileType <> "txt" Then
                  Response.ContentEncoding = (Encoding.Unicode)
                  'End If

                  If sMode = "dl" Then
                        ' Opens it outside browser
                        Response.AddHeader("content-disposition", "attachment; filename=" & sFile)
                  Else
                        ' Opens it inside browser
                        Response.AddHeader("content-disposition", "inline; filename=" & sFile)
                  End If

                  ' Opens it outside browser
                  Response.AddHeader("content-disposition", "attachment; filename=" & sFile)

                  ' Opens it inside browser
                  'Response.AddHeader("content-disposition", "inline; filename=" & sFile)

                  Response.BinaryWrite(MyData)
                  fs.Flush()
                  fs.Close()Start Free Trial
[+][-]05.14.2008 at 06:45AM PDT, ID: 21564072

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: MS SQL Server, Programming for ASP.NET
Sign Up Now!
Solution Provided By: DanielWilson
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.14.2008 at 06:57AM PDT, ID: 21564226

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628