Last post Aug 28, 2017 07:27 AM by Edward Z
Aug 25, 2017 11:18 AM|IamGuy84|LINK
I am using Aps.net core. Here is my sample code:
public FileStreamResult DownloadPoliceReport([FromRoute] int id)
var getFile = _context........;
MemoryStream ms = new MemoryStream(getFile.Data);
return new FileStreamResult(ms, getFile.ContentType);
This code seem ok.
I want to avoid automatic downloading in browser if i get doc file in Iframe.
I am waiting your response.
Thanks in advance!
Aug 25, 2017 04:31 PM|Dmitry Sikorsky|LINK
The browser behavior on file download is controlled by the content type of the file. So if you are downloading an image as image/png it will be opened in the browser as link. If you downloading the same image, but set content type to application/octet-stream,
it will be downloaded as file.
So try to play with content type.
Aug 28, 2017 07:27 AM|Edward Z|LINK
Has your issue been resolved?
Based on your description, it seems you want to show doc file in IFrame, I suggest you try
Office Web Viewer: View Office documents in a browser, and here is a simple code:
<iframe src="https://view.officeapps.live.com/op/view.aspx?src=http%3a%2f%2fvideo.ch9.ms%2fbuild%2f2011%2fslides%2fTOOL-532T_Sutter.pptx" width="402" height="346" frameborder="0" scrolling="no">
For another way, I think you could upload the file to OneDrive and then there is one option called “Embed” which will generate IFrame tags. You could place the generated HTML to the view.