I'm looking for some suggestions on how to go about this. Any input is appreciated!
Currently, I have an ASP.NET MVC application. On the client, I have a link with an ID of an XPS document. When the user clicks the link, they are taken to a page with details about the document. In addition to this information, I wish to display the document along side of this information, in the same page.
On the server side, once I have the ID, I can get the document, serialized as a byte array, from the database. The question is, what's the best way to get that serialized document into the webpage?
I would SEVERELY prefer not having to drop that document into the file system and then munge together a file path. I would like to be able to stream the document to the browser as a content type of "application/vnd.ms-xpsdocument".
I've tried using a web control to handle this (can't write binary out), thought about creating a HTTP handler to do this (no idea where to start), and have fuddled around with a couple other ways to get the document stream to the browser.
In addition, there is also the question of how to embed the document in the web page. Do I use an EMBED tag? Or an Object? Or do I use an iframe and set the source to point to whatever delivers the document?
Again, I don't expect a solution wrapped up in a bow. I'm looking for some advice on how to go about this. And, while this question is about xps documents, it applies to any application that streams a binary file that is to be hosted in a browser (PDFs, etc).
Okay, as for displaying in the browser, one word: Silverlight. That's solved. I still have the issue of figuring out the best way to send it from the server to the browser.
Strike that. It appears Silverlight isn't advanced enough to display an XPS document just quite yet. I'm thinking about an iframe pointing to a http handler now... The iframe works. Too bad it throws the entire thing down the pipe. I suppose I could always strip off the first page and send that puppy...
Wow. No need for a HTTP handler. A custom ActionResult in MVC is all you need. How friggen awesome is that?