filecontentresult

Handling FileContentResult when file is not found

十年热恋 提交于 2019-11-30 13:17:24
I have a controller action that downloads a file from an azure blob based on the container reference name (i.e. full path name of the file in the blob). The code looks something like this: public FileContentResult GetDocument(String pathName) { try { Byte[] buffer = BlobStorage.DownloadFile(pathName); FileContentResult result = new FileContentResult(buffer, "PDF"); String[] folders = pathName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); // get the last one as actual "file name" based on some convention result.FileDownloadName = folders[folders.Length - 1]; return result;

Handling FileContentResult when file is not found

爷,独闯天下 提交于 2019-11-29 18:28:41
问题 I have a controller action that downloads a file from an azure blob based on the container reference name (i.e. full path name of the file in the blob). The code looks something like this: public FileContentResult GetDocument(String pathName) { try { Byte[] buffer = BlobStorage.DownloadFile(pathName); FileContentResult result = new FileContentResult(buffer, "PDF"); String[] folders = pathName.Split(new char[] { '\\' }, StringSplitOptions.RemoveEmptyEntries); // get the last one as actual

Stream file using ASP.NET MVC FileContentResult in a browser with a name?

不问归期 提交于 2019-11-26 16:03:29
Is there a way to stream a file using ASP.NET MVC FileContentResult within the browser with a specific name? I have noticed that you can either have a FileDialog (Open/Save) or you can stream the file in a browser window, but then it will use the ActionName when you try to save the file. I have the following scenario: byte[] contents = DocumentServiceInstance.CreateDocument(orderId, EPrintTypes.Quote); result = File(contents, "application/pdf", String.Format("Quote{0}.pdf", orderId)); When I use this, I can stream the bytes, but a OPEN/SAVE file dialog is given to the user. I would like to

Stream file using ASP.NET MVC FileContentResult in a browser with a name?

佐手、 提交于 2019-11-26 04:41:02
问题 Is there a way to stream a file using ASP.NET MVC FileContentResult within the browser with a specific name? I have noticed that you can either have a FileDialog (Open/Save) or you can stream the file in a browser window, but then it will use the ActionName when you try to save the file. I have the following scenario: byte[] contents = DocumentServiceInstance.CreateDocument(orderId, EPrintTypes.Quote); result = File(contents, \"application/pdf\", String.Format(\"Quote{0}.pdf\", orderId));