filecontentresult

Read file and its properties from API and download it in Angular Client

最后都变了- 提交于 2021-01-20 13:26:07
问题 Need to download dynamic files which is returned from the api in the client side based on its type. This is what i have My api controller it looks like this public async Task<IActionResult> GetFile(int id) { IBaseResult<UserDetails> result = await _Bo.GetUSerDetails(id); //result will have content likes //1. FileName//fileaname.{extention} //2. FileType//eg.application/pdf or application/doc //3. FileContent//byte[] if (result.Data != null) { response.Success = result.success; response.Data =

Read file and its properties from API and download it in Angular Client

戏子无情 提交于 2021-01-20 13:26:05
问题 Need to download dynamic files which is returned from the api in the client side based on its type. This is what i have My api controller it looks like this public async Task<IActionResult> GetFile(int id) { IBaseResult<UserDetails> result = await _Bo.GetUSerDetails(id); //result will have content likes //1. FileName//fileaname.{extention} //2. FileType//eg.application/pdf or application/doc //3. FileContent//byte[] if (result.Data != null) { response.Success = result.success; response.Data =

How can I call an MVC FileContentResult by Jquery and get it to prompt the user to save on it's return?

守給你的承諾、 提交于 2019-12-30 10:14:32
问题 I'm generating a CSV from an MVC 3 website and using a FileContentResult to pass this to the user. This worked great but it took 30 seconds for the csv to generate and therefore 30 seconds before the prompt to save was given to the user. public virtual FileContentResult GetSpreadsheet(string id) { var service = new SpreadsheetService(); var result = service.GetCSV(); return File(new System.Text.UTF8Encoding().GetBytes(result.Message), "text/csv", "Report123.csv"); } So I thought I'd just call

How can I call an MVC FileContentResult by Jquery and get it to prompt the user to save on it's return?

China☆狼群 提交于 2019-12-30 10:14:09
问题 I'm generating a CSV from an MVC 3 website and using a FileContentResult to pass this to the user. This worked great but it took 30 seconds for the csv to generate and therefore 30 seconds before the prompt to save was given to the user. public virtual FileContentResult GetSpreadsheet(string id) { var service = new SpreadsheetService(); var result = service.GetCSV(); return File(new System.Text.UTF8Encoding().GetBytes(result.Message), "text/csv", "Report123.csv"); } So I thought I'd just call

ASP.NET MVC: Can an MSI file be returned via a FileContentResult without breaking the install package?

孤者浪人 提交于 2019-12-23 11:59:17
问题 I'm using this code to return a FileContentResult with an MSI file for the user to download in my ASP.NET MVC controller: using (StreamReader reader = new StreamReader(@"c:\WixTest.msi")) { Byte[] bytes = Encoding.ASCII.GetBytes(reader.ReadToEnd()); return File(bytes, "text/plain", "download.msi"); } I can download the file, but when I try to run the installer I get an error message saying: This installation package could not be opened. Contact the application vendor to verify that this is a

Asp.net MVC FileContentResult - prevent opening in browser

£可爱£侵袭症+ 提交于 2019-12-13 13:13:22
问题 One of my controller actions returns a file to the user. I would like the user to be presented with the download (open/save) dialog, regardless of the file type. This works fine when the file type is .doc, .docx, .xlsx, etc.., but when the file is .txt, .xps, .pdf (sometimes), or .html, it opens in the browser. Is there a way I can prevent the file from opening in the browser, and only allow the user to open it in a separate window without navigating away from the current page? The request

“File couldn't be downloaded” in Internet Explorer with ASP.NET MVC

╄→гoц情女王★ 提交于 2019-12-12 10:50:13
问题 So I'm returning a FileContentResult from an action like this: return File(pck.GetAsByteArray(), "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "MyExcelFile.xlsx"); When clicking "Open" in IE (I'm using IE9, version 9.0.8112.16421), it says "File couldn't be downloaded" and the user is presented with a 'Retry' button. If they click Retry, it works fine. If they click Save, it works fine. In Firefox, it works fine. How can I allow the user to open the file when the click

Rendering image in a View

China☆狼群 提交于 2019-12-12 01:45:45
问题 I'm trying to show some picture for user in a strongly typed View.. In Model members there is one that represents contents of image (ex. jpeg) How should I pass this content to img tag to render this image? model looks like: publiс class Image { public virtual FileContentResult currentImage { get; set; } public Image() { currentImage = createSomeImage(); // createSomeImage returns new FileContentResult(bmpBytes, "image/png"); } } View looks like @model app.Models.Image <img src='@Model

How can I call an MVC FileContentResult by Jquery and get it to prompt the user to save on it's return?

喜夏-厌秋 提交于 2019-12-01 07:33:20
I'm generating a CSV from an MVC 3 website and using a FileContentResult to pass this to the user. This worked great but it took 30 seconds for the csv to generate and therefore 30 seconds before the prompt to save was given to the user. public virtual FileContentResult GetSpreadsheet(string id) { var service = new SpreadsheetService(); var result = service.GetCSV(); return File(new System.Text.UTF8Encoding().GetBytes(result.Message), "text/csv", "Report123.csv"); } So I thought I'd just call it via JQuery - but this (unsurprisingly!) just dumps the CSV to the page. $.post("/Home

Best way to render System.Drawing.Image in ASP.NET MVC 3 View

ⅰ亾dé卋堺 提交于 2019-12-01 01:43:22
问题 I have an object of type System.Drawing.Image and would like to display this image in a view. What would be the best way to do this? I have found some custom Html Helper methods that might fit the situation. Also found an example that uses a new action method that returns a FileContentResult in order to pull something like this off. I would like to know what technique is best and easiest to implement. EDIT To be more specific, I have the image in a System.Drawing.Image variable in the