Best Practices for Exchanging data between Desktop and Web Application - c#

I have to pass information from a desktop application to Web application and vice versa.
What are the best practices that are regularly used?
Currrently I'm using Asp.Net and a Winforms.
To pass data to Web Site im creating a (POST) WebRequest and posting an xml to the site.
To pass data to Application im using .Net Remoting from Asp.net
(I'm using Winforms is an adminstration and monitoring application.)
Edit: Lets treat it as a generic web app and winforms.
Also currently both Web app and Winforms are on the same machine.(but can change).

Web Services or Windows Communication Foundation (WCF) would be your best bets for remote interoperability.
On your website, expose some service end points and consume them from your desktop app. Then send messages as you require.

I'd look hard at the design of the system and consider whether it's necessary to use a Winforms application at all for monitoring and administration. No, really: creating rich Web sites is quite straightforward (if necessary, with technologies like AJAX) and the architecture of the resulting application will be much, much simpler.
And, of course, deployment is then really simple.

I am not sure if there is a best practice for what you are trying to accomplish. There might be some security concerns you have to think about when allowing posts to your web application however. It would be very easy for a potential attacker to manipulate the post data and send it to your web application. You should consider using web services or Windows Communication Foundation.

Register a custom handler like how Real player registers rstp:// or for that matter web browsers register http://

Related

Building a remote command for Elpis in C# through HTTP API

I am helping to build Elpis, which is an open source pandora music player, built with C# and WPF.
Now what i want is to add an HTTP API so that the user may control the program through a browser, like play/pause, like/dislike the current song.
The point afterwards is to control the program through a mobile device accessing the HTTP API.
How exactly should i build the HTTP API so that it can control it?
Github for the project: https://github.com/adammhaile/Elpis
Without knowing why exactly you want the user to control a GUI application via the browser, it's hard to give you good advise.
Assuming you are running your GUI on Windows, take a look at OWIN and the project Katana. They allow you to easily host HTTP interfaces in your own application.
It may be overkill for your project but I would suggest using ASP.NET Web API so that you can build backend web services.
The easiest way to do what you want, assuming you really want to "control the GUI remotely" is to just install TeamViewer on your PC and on your mobile device. Then you could remote in and completely control your GUI.
But I what I think you're after is something more like Google Music. Where you can stream your music through the Internet and onto your mobile devices. If this is the case, I recommend you look at the ASP.NET Web API.
It's not hard to build a web server in C#. You can embed it into your application, and expose parts of your application to HTTP endpoints as an API. You can use the HttpListener class which is part of .NET, and do everything from the ground up yourself. Or you could use something like Nancy, which is a lightweight framework that provides a lot of useful scaffolding like URL routing.
Ended up using Kayak(https://github.com/kayak/kayak) for my self-hosted API.
The example of integration can be seen here:
https://github.com/adammhaile/Elpis/blob/master/Elpis/WebInterface.cs

How to communicate between ASP.NET & C# Application

I am in the process of developing a project that will require communication both ways between a ASP.NET website and a C# Application.
For example if I wanted to click a button on an ASP.NET webpage to retrieve the status of something.
How could I implement this communication between them?
Please note I have never used ASP.NET before, hence my question.
You can use same database in both website and application. If you want to transfer something from application to website, like a file, then you will need a web service or WCF service. But your wish seems like a shared database by website and application.
I think You should go through this link.....it has all the basics of asp.net and c# in very easy manner compared to all the other websites....
http://www.w3schools.com/
You could make the C# application write data somewhere and have ASP.NET read it there. Either to a database (which makes the most sense), or to some file, like an XML or JSON.
Storing communication on a database seems like an easy way to do it.
You could use a webservice, but that would need to be hosted by the website. The application could still poll this to write and read when needed though.
I think I found what I was looking for:
A Beginner's Tutorial for Understanding Windows Communication Foundation (WCF)
http://www.codeproject.com/Articles/406096/A-beginners-tutorial-for-understanding-Windows

Looking to create a webservice for client authentication and need some advice

I am developing an android application to accommodate some desktop software that I created. I would like for the user of the mobile app to have to verify their identity through authentication. Basically the web service will have to act as a central hub to both authenticate and hold information that the android app will need. The way I think it should work is to
-Set up a central web service
-Allow user to create account from desktop client using email/password
-The desktop client will send the information to the webservice that the android app will need.
-when android app is authenticated it will then retrieve the data it needs that was posted from the client.
So basically the service will need to be able to send and receive data.
I will only be using .net (either C# or vb.net ) for the service, so this leads me to a couple of questions:
Should I be using WCF for this? If so should I create a WCF Service library or WCF Service application?
Should I be using the Sign Sign on service approach?
The web service doesn't need to be fancy it just needs to get the job done. Is their any boilerplate project templates or projects out their I could use to help build a foundation?
I recently discovered SudzC.com which generates classes and methods for Objective-C from the wsdl data of a .net web service, and I'm fairly sure it also does Android.
I have a huge catalog of fairly 'old' web services which pre-date WCF and they are currently working perfectly.
I should point out though that the SudzC service only shows you what it can do for you for free - to get the code you have to pay ~£20 for a one year pass.
We had something similar where I worked. We had to put together an Android app for the company. If you are on .net 4.0 or newer, you can take advantage of theWebApi. It can return json or xml. So, that means any platform can utilize it (desktiop, android, etc...). I found it extremely easy to use, with very little overhead.

Kendo + Web Api vs. MVC vs. Web Service Where to go?

I'm just starting a project where I would like to use Kendo UI (based on jquery) with C#. A few weeks ago I was successful in handling requests using Web Services (asmx), was pleased with the results and performance, and was able to create forms quickly.
Since this is a new project, I thought I could look into different concepts such as MVC and WebApi. I found MVC to be the most complicaded so I went for WebApi and started playing with controllers and requests. So far what I'm finding (don't judge me, I'm new to these new concepts), is that Web Service seems to be simpler and more flexible.
So I guess what I'm looking for is... what are the main advantages of using MVC vs WebApi and even vs Web Services. Are there any downsides to Web Services? Would it be a bad practice to have my data layer controlled by Entity Framework, all models defined, and my requests handled by Web Services?
Any clarifications are welcome. Thank you.
In a broader sense, Web API is used to create Web Services ! It uses HTTP as its standard for creating services (instead of SOAP like in asmx) as its more open and any type of client like a mobile app, desktop app, web app etc will understand HTTP protocol. Another advantage is that u can easily use JavaScript/jQuery to communicate with your Web API. With SOAP web services, its a nightmare!
Kendo UI and Web API is a great combination. We have recently created a mobile iPad app using this combination and it worked like a charm. We also used Entity Framework with oracle as back end DB and it never gave any issues.
Webservices are nice if you have the need for it. A need as in needing that logic/data in more than one different type of application (such as web, and a mobile app, and a desktop app). (Or if you want to sell the service you're providing)
Using a webservice for ONLY a website which you don't except to expand to other things is complete overkill.
Furthermore, the MVC framework and the Web Api framework are pretty similar except web api is used exclusively for webservices. Coding in both of them will be the difference between white bread and wheat bread.

Move UI of Windows Forms .NET application to web

I have written a windows forms (.NET C#) application that encodes video and is essentially a GUI for ffmpeg.
The requirement has changed, and we now want to move the UI to a web page and have the encoding done as a windows service.
The following requirements also apply:
Two-way communication between browser's web page and service (i.e. start encoding using web interface and have service notify progress back to web page)
Service should be ported to Mac OS X too
UI should be a standard webpage (should consist of HTML/CSS/JavaScript/Flash etc...)
I was thinking of WCF for the windows service, but I have zero WCF experience.
Will WCF provide a good basis for 2 way communication between the web page and the service?
Also, I need to think about porting the service to Mac OS X, and I noticed that WCF is only partially implemented in Mono (see http://www.mono-project.com/WCF_Development).
Will this be an issue? Does anyone have any experience with WCF development in Mono?
What would be the best route to meeting the requirements above?
I would love to hear any suggestions...
EDIT
I should clarify - this is not a web application, it will run entirely on client side.
Service should run client side and interact with a webpage inside a browser (which is also client side).
If you want a UI in HTML – which is what a "UI to a web page" would mean to most – then WCF is the wrong approach. WCF is for creating highly interoperable (WS-* standards) clients and/or servers; not for web pages.
Better looking at ASP.NET MVC. This is a very different model to WinForms,1 but allows easy moving from from rendering a UI into HTML to generating XML or JSON for a Web API (behind AJAX from a Web UI or a native client).
As I understand it ASP.NET MVC is substantially supported on Mono; and this should become easier with much of ASP.NET being open source now.
See also this answer from yesterday.
1 WinForms would be less of a move, but it would then be harder to do the API side without another technology shift (albeit ASP.NET WebForms and MVC can be easily mixed in one Web App).

Categories