Click here to Skip to main content
15,891,253 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
Below is my code which opens a word or spread sheet document when user clicks the image in browser.But i need to open that word/spread sheet document in the browser itself.How can i do this 


What I have tried:

i tried above code but its not working
Posted
Updated 19-Dec-16 18:39pm
v2

You can not force your way. The decision is for the end user as this is his computer...
You have to consider several issues:
1. User may has not application that can open the requested document type
2. Even user has such application, that application may not play well with the browser, so no way to open the document inside the browser anyway...
3. Even in the most comfortable setup, user can decide that he wants the files to be downloaded and not displayed, or opened outside the browser in any case...

In any case it should not be your concern how the end user receives the file - simply supply it...

BUT! If you have customers like mine (PITA)... You have to write (borrow) some viewer of your own or let them install some extensions for the browser (depends on the browser)...
 
Share this answer
 
Your .net code is running on the server so you're starting the process on the server so the file is being launched on the server. Your .net code isn't running inside the browser or on the client machine. This code will have worked when developing the site as the server and client are the same machine, but when you are on a remote server it is going to stop working.

Google for "asp.net send file to client" and you'll find some proper code. If the MIME type is correct for the file it gives the best chance the file will open in the browser, but as said in Solution 1 it depends on various things, there is no way to force the file to open in the browser.
 
Share this answer
 
Quote:
How to open open office spread sheet document in browser using ASP .NET C#
Short answer: you don't.
The browser can't launch arbitrary app on client side, it is a security feature.
The only thing that the browser can do is launch apps registered with a plugin like pdf reader or if you download a file and allow app launch, but it imply user validation.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900