5

Does anybody happen to know if it is possible to develop a .NET based desktop app in Visual Studio with HTML5 as a front-end?

I know the answer on MSDN a couple of years back seemed to be no, but I'm wondering if there has been any change.

I know you can develop JavaScript based desktop apps with things like Chrome Apps, but I'm wondering if you can do the whole thing (except for the UI) in .NET in Visual Studio. I'm also aware I could code it all in JavaScript and talk to .NET web services, but again I just want it all in the desktop app.

ChrisC
  • 1,161
  • 12
  • 26
  • One could try bridge.net. It is a C# to JS transpiler, so you write code in .NET and gets executed as JS/HTML5. It seems to have a C# API for HTML manipulation, so you dont have to necessarily directly deal with HTML. There is also cshtml5.com which is just the same except it is C# and XAML instead of pure C#. – nawfal Apr 15 '16 at 10:17
  • A pure C# + HTML solution would be Sciter. There is a C# binding for it called [SciterSharp](https://github.com/midiway/SciterSharp) – nawfal Apr 28 '16 at 12:37

3 Answers3

4

You can use DotNetBrowser library to use HTML5 in .NET desktop applications.

The library provides a Chromium-based WPF component that can be embedded into your .NET application. The component supports calling JavaScript from C# and vice versa. Chromium engine will act as a HTML5 interpreter in this case.

Here's code example that demonstrates how to load HTML into the component and get HTML of the loaded web page:

using System;
using DotNetBrowser;

namespace MyNamespace
{
    class Program
    {
        static void Main(string[] args)
        {
            // Provide path to the directory with DotNetBrowser Chromium binaries.
            Environment.SetEnvironmentVariable("DOTNETBROWSER_BIN_DIR", @"D:\Library\Chromium");

            // Create Browser instance.
            Browser browser = BrowserFactory.Create();

            // Register frame loading event listener.
            browser.FinishLoadingFrameEvent += delegate(object sender, FinishLoadingEventArgs e)
            {
                // Wait until main document of the web page is loaded completely.
                if (e.IsMainFrame)
                {
                    // Get HTML of the loaded web page and write it to Console.
                    Console.Out.WriteLine(e.Browser.GetHTML());
                }
            }
            // Load HTML content from string .
            browser.LoadHTML("<html><body><h2>Hello World!</h2></body></html>"); 
            // Load google.com to get its HTML content.
            browser.LoadURL("http://www.google.com");
        }
    }
}

To find out how to configure MS Visual Studio 2013 Project with DotNetBrowser you can take a look at Quick Start Guide.

It's free for Open-Source projects ;)

Anna Dolbina
  • 1
  • 1
  • 8
  • 9
  • 1
    Thanks Anna. This is no longer a requirement for me so I won't be trying it anytime soon, but as this does seem to answer the question I'll mark it as the answer. – ChrisC Jun 05 '15 at 15:04
  • DotNetBrowser requires a license, however. Is there any free alternative? – DARKGuy Dec 30 '17 at 22:19
0

If you are thinking about a Windows 8 Store app that runs on a desktop (full-screen "metro" app) then they did make JavaScript a first-class citizen for WinRT.

Create your first Windows Store app using JavaScript (MSDN Article)

CodingWithSpike
  • 42,906
  • 18
  • 101
  • 138
  • 1
    No, I mean a traditional desktop app. – ChrisC Aug 27 '14 at 18:13
  • This post has a breakdown of some different options: http://clintberry.com/2013/html5-apps-desktop-2013/ I would venture to guess that none of them are as good as native, but may suit your needs. – CodingWithSpike Aug 27 '14 at 18:31
  • 1
    Thanks for that, but I don't see any mention of using .NET in the backend for any of those options mentioned. I'm getting the impression that this isn't possible at this time. – ChrisC Sep 02 '14 at 13:44
0

We write angular front ends and set chrome as the desktop process rather than explorer. Chrome runs in kiosk mode. Have IIS runing c# asp.net back end

Neil
  • 681
  • 2
  • 6
  • 12