Working with WebWindow — To Use Kestrel or to not use Kestrel?
Simpler is better? What is simpler? In the wise words of every teenager — It’s Complicated.
Previously, I decided I wanted to write a better money app, but I wanted to use web technology, since I’m much more comfortable with it and tend to prefer it over Windows Forms or WPF. Plus, the web tends to be more portable.
However, I wanted the security of a local desktop application for my finances. I’m tired of Plaid selling my data just so I can view my accounts in Money in Excel. It’s not like Excel is even a free tool — it’s part of Office 365, which, last I checked, is a paid subscription. So why would my data be at risk? Welcome to today’s world.
Anyway, I didn’t want my program to be more of the same. I want my information locked tight on my client. But, is there any way to bring the web to my desktop? Sounds like a stupid question. Sure, I could load up IIS, start a localhost website, start an SQL Server instance, and keep it running on my local machine. Not very portable though — good luck installing that. Let’s skip IIS & SQL Server, but let’s still try to use a web view of some sort. Well, look no farther than WebWindow — for an experimental example.
WebWindow
WebWindow is a pretty cool library. It exposes a one-line command that would let you run a Blazor app by providing the Startup class and the path to the index page (e.g. index.html). But that’s here my difficulty started.
Now, when we call the Main method, this will call UseWebView, which will start a Windows Form Application inside the .NET Host that contains a WebView2. We still have a few things to tidy up:1. Plugin url to WebViewForm so it loads the proper localhost url2. Move Windows-specific code to Thunder.WebView.Windows3. Ensure Blazor can communicate properly in WebView.4. The hosted application can communicate to the UI Host (e.g. Windows Forms) to do things like open/save files or other similar actions.
We’ll look more into each topic in future installments. The Github commit for this is here.