点击页面视图:
@Html.ActionLink("预览", "pdfview", New With {.id = item.fwname}, New With {.target = "_blank"})
Public Function pdfview(ByVal id As String) As ActionResult
Dim path As String = "\\172.16.11.7\gcpic\file2\twfx\" & Trim(id)
If System.IO.File.Exists(path) Then
Dim temfile As New IO.FileStream(path, IO.FileMode.Open, IO.FileAccess.Read)
Dim bytes As Byte() = New Byte(temfile.Length - 1) {}
temfile.Read(bytes, 0, bytes.Length)
temfile.Close()
Return File(bytes, "application/pdf")
Else
ViewBag.err = "无效的文件"
Return View("error")
End If
End Function