我從昨晚開始一直在尋找這個,並且無法弄清楚如何解決它。類型FileResult和FileStreamResult未定義,我該如何解決?
2個錯誤,一個說,Type FileResult is not defined
。
另一說,Type FileStreamResult is not defined
。
Imports System
Imports System.IO
Imports System.Collections.Generic
Imports System.Text
Imports EO.Pdf
Imports System.Collections.Specialized
Partial Class getRecs
Inherits System.Web.UI.Page
Public Function Download() As FileResult
' Populate list with urls
Dim qParams As String = Request.QueryString("p")
Dim urls() As String = qParams.Split(","c, ChrW(StringSplitOptions.RemoveEmptyEntries))
Dim documents = New List(Of EO.Pdf.PdfDocument)()
For Each url In urls
Dim doc = New EO.Pdf.PdfDocument()
EO.Pdf.HtmlToPdf.ConvertUrl(url, doc)
documents.Add(doc)
Next
Dim mergedDocument As EO.Pdf.PdfDocument = EO.Pdf.PdfDocument.Merge(documents.ToArray())
Dim ms = New MemoryStream()
mergedDocument.Save(ms)
ms.Position = 0
Return New FileStreamResult(ms, "application/pdf") With { _
.FileDownloadName = "download.pdf" _
}
End Function
End Class
在此先感謝。
是否有可能你正在試圖把MVC編碼成WebForms的項目? – 2012-07-25 14:07:04
@ J.Steen MVC和WebForms將很高興地融合在同一個項目中。 – Richard 2012-07-25 14:08:35
@Richard Quite,但是這將解釋缺失的進口,正如你已經回答的那樣。試圖將OP引導至他們自己的解決方案。 =) – 2012-07-25 14:09:09