[英]How to download a file via an ActionResult method?
I have this controller endpoint where an form can be submitted, and and in case a specific form is being is being used it should "autodownload" a file generated based on the input provided from the user.我有这个 controller 端点,可以在其中提交表单,如果正在使用特定表单,它应该“自动下载”根据用户提供的输入生成的文件。
How do I go about this?我怎么go一下这个?
I have tried this我试过这个
public ActionResult SubmitForm()
{
if(specificForm)
{
byte[] file = GenerateFile(Request)
return File(file, "application/x-pkcs7-certificates", "cer.p7b");
}
...
return ()
}
but no download seem to start, I assume its because the controller force it to be an action result rather than a FilecontentResult?但似乎没有下载开始,我假设它是因为 controller 强制它成为操作结果而不是 FilecontentResult?
How do I go about this?我怎么go一下这个?
Turned out that the site was being redirected to another page.原来该网站被重定向到另一个页面。 Which caused the response to never reach the user这导致响应永远无法到达用户
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.