OfficeViewer display file from memorystream

0
0

Hi,

I am trying to display file in Wisej.Ext.OfficeViewer control.

When i am passing this.officeViewer1.FileSource = URL of publicly available file it is working correctly.

As I would like to avoid saving files on the server, so I am trying to use memorystream.

this.officeViewer1.FileName = “Report.xlsx”;
this.officeViewer1.FileStream = ms;

But I am getting the error “An error occurred We’re sorry, but for some reason we can’t open this for you.”

What am I doing wrong?

D

  • You must to post comments
0
0

Hi Dino,

The OfficeViewer extension requires that whichever file you’re trying to access is available at a public endpoint.

In the case of the MemoryStream issue, it doesn’t work because you’re running it on localhost.

If you dive into the source code, you see that the extension contains a handler for incoming HTTP requests from the outside and checks for the specified file name.

https://github.com/iceteagroup/wisej-extensions/blob/6e8d112136fc710021c9a5ba79d1c432d028c8be/Wisej.Web.Ext.OfficeViewer/OfficeViewer.cs#L232

 

If Microsoft can’t access your application (because it’s on localhost), it won’t be able to serve the file through the OfficeViewer.

 

You can see on line 250 that it attempts to return the FileStream specified as a response to the HTTPRequest.

https://github.com/iceteagroup/wisej-extensions/blob/6e8d112136fc710021c9a5ba79d1c432d028c8be/Wisej.Web.Ext.OfficeViewer/OfficeViewer.cs#L250

 

If you want to test it, you’ll need to publish your application to a publicly-accessible URL.

 

HTH

Best Regards,

Levie

  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.