Click here to Skip to main content
16,018,818 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
want to open selected ms office file from browse dialog box and open using locally installed respective application.

What I have tried:

Tried through active x control with microsoft.office.interop tools.

But failed to load application.
Posted
Updated 25-Jan-20 4:48am
Comments

Browsers are not allowed to do this for security reasons.
 
Share this answer
 
To expand on Richard's excellent answer: C# code runs on the server, javascript runs on the client. Javascript cannot - for security reasons - execute any application on the client machine, and has no access to the server to run apps either.

So any app you can start from your C# code will run on your server, not on the client. While it may appear to work in development, that's because the client and the server are the same machine - it will not work in production, because the user will not be able to see any results on his machine.

C# code cannot access or cause to run any application on a client computer directly - for very, very good security reasons: if you could do it, so could ransomware and virus writers, and the problems they cause today would be trivial compared to the problems they could cause if you could execute software on client machines outside of the browser.

Many, many year ago, MS looked at this and thought "It'd be nice to run apps on the client" and includes support for ActiveX controls into IE. The rest of the world looked at this in horror, called the developers morons, and immediately disabled it, as well as not including any such support in any other browser. Microsoft quickly changed the defaults for ActiveX support even in IE to "No elephanting way, José" and did not include ActiveX even in the execrable Edge, such was their shame.

The only machines that you could do this on would be ancient, un-updated, and probably pre-XP machines running an ancient version of IE. This amounts to maybe 0.0001% of all available machines. And they won't have a modern version of Office installed in order to load the documents anyway ...
 
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