4

I am looking for a way user can communicate between an ASP and Winform applications.

I am looking for something like soluto.com, I want to let the user send commands to other computers via Website. So let's say the user signed up for 10 computers, which is registered on the mvc app. User can select all the 10 computer and send a "Do this task" with a click of a button.

I am thinking something like, Winform will create a httplisten server. Everytime winform is open, it will send a "I am online" post to mvc, along with IP:Port. The server will send a request to that ip:port when required.

That approach seems very unsecure though, having an open port, configuring firewall and etc, seems like a overkill.

I was wondering if there way any other way of accomplishing this.

Thank you for the help.

P.S. Before you claim this is a stupid idea, Piriform is doing something like this also. Take a look at Agomo.com

tereško
  • 58,060
  • 25
  • 98
  • 150
JohnC1
  • 841
  • 1
  • 12
  • 27

3 Answers3

4

Use SingalR with properly architected web and windows applications (e.g. MVP, MVC, etc.)

SignalR with window client (WPF)

Console App & SignalR

John S.
  • 1,937
  • 2
  • 18
  • 28
  • There are other publish/subscribe frameworks like NServicebus (http://particular.net/NServiceBus) to look at too. – Jun Wei Lee Oct 05 '13 at 02:34
0

Create a WCF service within the WinForm application, specify endpoint(s) (and secure the endpoint appropriately), and connect to said endpoints from your ASP.NET application the same way you would also connect to a WCF service.

Moho
  • 15,457
  • 1
  • 30
  • 31
0

Why don't you just have the Winforms app use a standard HttpClient or WebRequest to periodically poll the service (maybe every 5 seconds or so) and ask if there if there are any tasks that need to be performed?

Unless you need realtime, low-latency, high performance communication then this is the easiest way to solve your problem with minimal to zero client side setup or security configuration.

The way I would do it is implement it like a stack in a data persistence layer. So each client could have rows in a table that are added when a task is queued. When the clients sends an HTTP GET request to the MVC server it will return the an array of tasks for that client and you could have it either delete them from the database right away or wait for the client to send a HTTP command later to indicate which tasks it completed.

You could represent tasks as a simple data object with a few properties, or just a string or int that you can lookup on the client in some way to invoke the appropriate code.

For reasonable security each client just needs to be given a unique key like a GUID or equivalent that it can later send to the server to validate its identity. This is also known as a cookie, secret, or API key.

Trevor Elliott
  • 11,292
  • 11
  • 63
  • 102
  • This is what I was thinking but won't it be trouble some having WinForms sending requests like every minute? I have 200 downloads a day on my program. So, let's say in a year, that'll be a LOT of program querying my server. Still better than real time I suppose. – JohnC1 Oct 05 '13 at 02:24
  • What you really want is a publish/subscribe model, which is what @John S. has answered. Polling can also be slow, and also incurs a lot of overhead. – Jun Wei Lee Oct 05 '13 at 02:33