【发布时间】:2013-12-05 23:13:51
【问题描述】:
我正在开发一个使用从 WPF 应用程序中托管的 Nancy 的小项目。我希望能够远程下载大约 8MB 的 PDF 文件。我能够让下载工作,但在下载过程中,应用程序不会响应任何其他请求。有没有办法让我在不占用所有其他请求的情况下允许文件下载?
Public Class ManualsModule : Inherits NancyModule
Public Sub New()
MyBase.New("/Manuals")
Me.Get("/") = Function(p)
Dim model As New List(Of String) From {"electrical", "opmaint", "parts"}
Return View("Manuals", model)
End Function
Me.Get("/{name}") = Function(p)
Dim manualName = p.name
Dim fileResponse As New GenericFileResponse(String.Format("Content\Manuals\{0}.pdf", manualName))
Return fileResponse
End Function
End Sub
End Class
或者在 C# 中
public class ManualsModule : NancyModule
{
public ManualsModule() : base("/Manuals")
{
this.Get("/") = p =>
{
List<string> model = new List<string> {
"electrical",
"opmaint",
"parts"
};
return View("Manuals", model);
};
this.Get("/{name}") = p =>
{
dynamic manualName = p.name;
GenericFileResponse fileResponse = new GenericFileResponse(string.Format("Content\\Manuals\\{0}.pdf", manualName));
return fileResponse;
};
}
}
【问题讨论】:
标签: nancy