0

I'm developing windows application in C# .I have website which is developed in ASP.NET C# which contains button desktop app when user click on this button he redirect to desktop app user login and upload videos from computer to server .But my problem is how to interact windows app with asp.net c# web application.User upload videos and then show notification in web.

Balagurunathan Marimuthu
  • 2,927
  • 4
  • 31
  • 44
Fawad Khan
  • 17
  • 7

1 Answers1

0

IMO there are multiple approaches to this.

  1. You can make the user download the EXE and then run the same
  2. If you know the location of the EXE on the user's machine, you can use JavaScript ActiveX object to execute it
  3. You can register a URI scheme on the user's computer and when user clicks on the link the link (like myexe://exePathOrDescription) the respective shell command will get executed thus running the executable (btw, this is how skype call buttons on web page and magnet torrent links work)

1. Download EXE and run the same This is the easiest approach where the user will click a link like <a href="/internalServer/unknownFile.exe">Do not run this file</a> and then he/she will be asked to save or run the file. The user can click on 'Run' and after download is completed, the application will be executed by the browser.

2. If you know the path to file, you can use JavaScript

var activeX = new ActiveXObject("WScript.Shell");
activeX.Exec("C:\\folder\\executable.exe");

Note: ActiveXObject is available on IE only. For other browsers refer to the responses to this SO question

3. Register URI Scheme (btw, my favorite) Here you can create a utility application which will be needed to be downloaded and executed for once to register the URI scheme, or alternatively, you can add code to your application to register the URI scheme when the application is executed for the first time.

Then you can create links on your web page that start with your URI scheme (like myExeScheme://pathToExecutable_URLEncodedWillBeBetter). When the URI scheme is registered on user's machine, when the user clicks on the above link, the respective Shell command (defined during the creation of URI scheme) will be executed and thus your application will be executed.

After the application is executed, the user can proceed with login and other tasks on the application.

To register URI scheme refer to the responses to this SO question


For second part: Uploading images from desktop Windows

You can create a web service to which you will push image/video data encoded as Base64 string and then decoded on server after receiving. Now the string could be very large so you may need to upload the data in chunks like 1KB data in one request, and while doing so you will have to plan a strategy regarding how will you maintain the sequence of the data uploaded.


3rd Part: How to show notification on web page

You can use JavaScript/JQuery/AJax to continuously check on server if a new file is loaded (you can restrict the number of requests form the page by employing logic like request will be sent only after use clicks on the desktop app button on the web page, etc). When a new file is loaded, popup the notification message.

HTH.

Community
  • 1
  • 1
Manish Dalal
  • 1,768
  • 1
  • 10
  • 14