Click here to Skip to main content
15,883,853 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I can get close: by purchasing an EV certificate from Digicert, I can compile my code and put it in a href link on my website. When a user clicks the href link, the file is downloaded. A second click on the downloaded file runs it, with no further ado thanks to the EV certificate. I'd like to cut down the two clicks to one, since eventually I'd like to have students choose among several dozens of demonstrations to run.

What I have tried:

I've tried to use ClickOnce to compile it, but despite the promising-sounding name, it delivers no more than a politician's promise. I get a similar user experience using it, but worse: it still requires two clicks from the user's perspective, but now the user's second click is followed by a wait while the setup program verifies the files present against the manifest.

Is there in fact a way to have the browser download and automatically launch the code, or am I barking up the wrong tree - is this a property of the browser, and therefore unsolvable (since each user will have different browser settings) - does it really require me to reprogram things in JavaScript and embed that in my pages?
Posted
Updated 19-Oct-18 11:33am

You can't.
The whole idea is that nothing - but nothing - runs directly on the client machine unless the user actually tells it to.
Your site has no control over what happens to downloads of any form, it is all down to the browser and how the user instructs it to behave.

Think about it for a moment: WannaCry infected loads of computers becuase users ran it: if it could run without the user having anything to do with it, then a casual or accidental visit to a malicious site could run something like that directly on your computer. How fast and how far do you think WannaCry would have spread then?
 
Share this answer
 
Quote:
I'd like to cut down the two clicks to one, since eventually I'd like to have students choose among several dozens of demonstrations to run.
You can't because of a silly thing named 'Security'.
Download and execution on client side are client decision.
My browser is set so that it always ask me what to do with a download, execute or store and where to store, no matter the certificate you are using.
Quote:
Is there in fact a way to have the browser download and automatically launch the code

Think about it, it is a dream for any malware maker.
 
Share this answer
 
I agree with the above comments that the ability to auto-run code from a website that can read to or write from the user's drive poses a major security risk. Yet, I don't think my question is naive. I currently have an interactive program on my pages inside a .svg container that executes on the client machine without the user doing anything other than visiting the page, for instance.

I would think there would be some option to allow one to do the same in a C# app, perhaps by limiting code privileges as a "partially-trusted" option, reserved for non-reflective code that has no access to drives. It indeed may be impossible to do so, but I don't see how such a limited-trust program would be any more a malware writer's dream than an .svg that provides the same functionality as my screen-write-only programs.

It sounds like I may have to move away from C# and recode everything in JavaScript or .svg's that provide the functionality I seek. I just prefer writing complex code in a type-safe language.
 
Share this answer
 
v2
Comments
Richard MacCutchan 19-Oct-18 9:06am    
How would you prove that your application is "partially-trusted", and not just malware in disguise?
Dave Kreskowiak 19-Oct-18 9:08am    
SVG is for Scalable Vector Graphics. It's drawn by the browser itself. There's nothing to really "execute". It's just interpreted and drawn according to the data in the file. Just drawing something isn't a serious security threat.

An executable is entirely different. It represents a massive security threat if allowed to run in an unsecured context. Core can do all kinds of hostile things to the client machine its running in. That's why it's not allowed any more, because it has happened.

There used to be stuff like WPF browser apps, Java, Silverlight, Flash, and whatnot. Those days are over because of security problems, not necessarily with the code being downloaded and run, but also with the browser plugins required to run that code.

That was another problem with doing such. Every browser needed a plugin to run the code. This approach has been abandoned in favor of Web Assembly. Put the ability to execute code directly into the browser and only execute the code in the secured sandbox environment in the browser. Though, support for this is mostly fleshed out in today's browsers, the tooling to generate Web Assemblies is still immature.

Browsers today are their own operating systems, running code in a virtual machine, but that environment is still being improved and expanded on.
Actually, the approach I use with .svgs interprets user clicks, computes a dynamically-calculated phasor, and then calculates a dynamically-calculated Fourier reconstruction and plots that in an animated fashion. I can make it do a lot more than just drawing static data from a file! I suppose that, or raw JavaScript, is what I'll need to convert all my demonstrations into.

Fair dinkum. Was hoping a similar option was available in a language that's typesafe...svg coding and JavaScript coding (and Flash, back in the day) is ugly in comparison. Thanks all.
 
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