Skip to content

Instantly share code, notes, and snippets.

@jz5
Created March 11, 2015 02:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jz5/b6f680309c04a80b1786 to your computer and use it in GitHub Desktop.
Save jz5/b6f680309c04a80b1786 to your computer and use it in GitHub Desktop.
Function FileStream(url As String) As ActionResult
Try
Dim req = HttpWebRequest.CreateHttp(url)
Dim res = DirectCast(req.GetResponse, HttpWebResponse)
Response.ContentType = res.ContentType
res.GetResponseStream.CopyTo(Response.OutputStream)
Catch ex As WebException
If ex.Status = System.Net.WebExceptionStatus.ProtocolError Then
Dim r = DirectCast(ex.Response, System.Net.HttpWebResponse)
Response.StatusCode = r.StatusCode
End If
End Try
Return New EmptyResult
End Function
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment