MVC Action 需要很长时间才能返回
我有一个带有操作的 MVC 控制器
public ActionResult GeneratePDF(string id)
{
FileContentResult filePath = this.File(pdfBuffer, MediaTypeNames.Application.Pdf);
return filePath;
}
,由于某种原因,当它到达返回线时需要 20 秒以上。
pdfBuffer 工作正常,当我在 VS 上运行它时一切正常,但是当我部署到 IIS 6 时它运行缓慢。
有人知道为什么吗?
I have an MVC Controller with an action
public ActionResult GeneratePDF(string id)
{
FileContentResult filePath = this.File(pdfBuffer, MediaTypeNames.Application.Pdf);
return filePath;
}
And for some reason it is taking over 20 seconds when it hits the return line.
The pdfBuffer is working okay, and when I run it on my VS all is okay, but when I deploy to IIS 6 it runs slow.
Anyone know why?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我尝试导出到 XLS 和 PDF 时,我遇到了类似的问题,唯一可以改善响应时间的方法是直接从生成文件的类发送响应,例如:
但如果这样做,您将得到一个 < code>“并非所有代码路径都从 ActionMethod 返回值”,以避免我们只发送:
最后一行实际上永远不会被执行,因为我们直接在方法上结束请求。
I was running into a similar issue when trying to export to XLS and PDF, the only thing that seem to improve the response time was sending the response directly from the class that generates the file like:
But if you do this you will get a
"not all code paths return a value"
from the ActionMethod, to avoid that we just send a:This last line will actually never be executed because we end the request directly on the method.