How do you launch a winform app from within an asp.net page?
How would you launch a winform app from within an asp.net开发者_运维问答 page?
If you have the ability to install the WinForm app up front, look at Application Protocol registration. It's described well by Mozilla here.
That would allow you to add a URL in your ASP.NET application along the lines of:
thing:SomethingThatThingUnderstands
Here's an example (from the page I linked to) of a URL link that would open OneNote:
<html>
<head>
<title>Test of onenote: application protocol</title>
</head>
<body>
<p>Open the
<a href="onenote://C:\Program Files\Microsoft Office\Templates\1033\ONENOTE\12\Stationery\BLANK.ONE"> Notebook.</a></p>
</body>
</html>
As it was already said I don't think you can do it. What you can do is to post a link to your application (or its installation package) on your website and let user to download and run it. There are obvious problems with that, e.g. for any .net application you would need .net runtime of the proper version to be installed on user's machine.
As an alternative to what you're trying to do, pls, take a look at the ClickOnce Deployment documentation on msdn; this might be a solution to what you're trying to do
For security reasons, the web and Silverlight and flash don't allow you to directly interact with users file systems as that would make virus writing way to easy.
Of course, you can do anything you'd like with an ActiveX control, provided your users accept the control.
This site provides a tutorial on launching an app for a client:
<SCRIPT Language="JScript">
function runcmd() {
File="cmd.exe";
WSH=new ActiveXObject("WScript.Shell");
WSH.run(File);
}
</SCRIPT>
<A href="#" onClick="runcmd(); return false;">Run CMD.exe</A>
Be aware that this will only work on IE and only after the user grants it access.
Why is it that you need to interact with the desktop application? Perhaps there's a better way to create this interaction.
If you really mean Winform, like your tag, rather than Webform, the answer is that you can't do it using just ASP, as that would be a significant security issue. You'd likely need an ActiveX control or similar.
Convert the winform application you wish to embed to the more web-friendly Silverlight.
精彩评论