Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to provide a web interface for a .Net application [closed]

I have a .Net (c#) application with a WinForms GUI. Besides that, I want to provide a secondary web GUI so the application can be controlled from another pc at the home of the user.

So part of the webpages (the values) should be filled in by the application.

The web interface should work out of the box, so no installation or configuration of third party software by the user.

What would be the best way to implement this?

And a second question: Once this is implemented, and I want to run my application on a server and provide access to multiple users on the internet, can I easily move to a more performant web server?

like image 493
Coder14 Avatar asked Mar 20 '23 14:03

Coder14


2 Answers

Here are some approaches you could take:

Lightweight

You could use a lightweight web framework like Nancy to serve the pages and have it get data from your application/database. Nancy was designed to run anywhere, which makes it more suited to building a desktop app. You can get a feel for Nancy syntax by reading Why use NancyFx.

Asp.net

Asp.net is usually used with IIS but it is possible to deploy as a desktop application. This Lunar Frog blog post describes how you might go about this. It mentions IIS Express which will need to be installed on your users machine using the official installer.

If you haven't done much web app development it may be best to follow an Asp.net Tutorial and build a dummy app first.


I've not used either myself. Asp.net is the first choice for most C# devs, and will help you learn about structuring a web app well. (REST, Controllers, Templates/Views etc.) But a lighter solution will help you get started quicker and may be more suitable for a desktop app.

Both options can be run on a separate server, but be careful to de-couple your business logic and database lookups from your two front ends (Gui and web). Nancy even claims to run on linux!


You will also need to decide between rendering data into a template, or using javascript to fetch the data.

Templates / View Engines

Both Asp.net and Nancy have their own preferred view engines like NHaml or TextTemplatingFilePreprocessor. Nancy describes the ones it supports here.

Javascript & JSON

Alternatively you could build an API which returns JSON, and use a front end javascript framework like Ember.js, Knockout.js or Angular.js to use that data.

like image 89
James EJ Avatar answered Mar 23 '23 01:03

James EJ


Web API ( http://www.asp.net/web-api ) can accomplish everything you need here.

Ideally (and in most cases) your WinForms app should back all its data to a database (preferrably through the API), and your Web Api will interact with the database, not the WinForms app.

Yes, you can move Web API to other servers in the future.

like image 33
kingPuppy Avatar answered Mar 23 '23 00:03

kingPuppy