Today
- Maui, Hawaii
Windows has support for an `ms-setting:` Protocol Handler/Uri Scheme that allows you to directly open most Windows settings dialogs directly via simple Url based shell commands.
Read more...
Saturday
- Maui, Hawaii
ASP.NET Core has support for resolving Urls in Controllers and Razor Pages via embedded `~/` links in Views and via `Url.Content()`. But, these features are tied to Controllers or Razor Pages - what if you need to resolve Urls elsewhere, in middleware or even inside of business logic? In this post I describe how you can build a couple of helpers that are more flexible and also provide some additional functionality of resolving site root and relative paths to full site root paths.
Read more...
February 26, 2025
- Maui, Hawaii
Confirmation dialogs or modal popups can be annoying in HTML applications. What if you could instead use an inline UI to confirm an operation? In this post I describe a simple way you can use an inline UI to confirm an operation that can be easily implemented with a few lines of code and a couple of binding directives.
Read more...
February 21, 2025
- Maui, Hawaii
The WPF Clipboard is notoriously bad for retrieving image data, mainly because of the funky behavior of the ImageSource control into which clipboard data is loaded. WPF cuts a lot of corners when retrieving images and there are many scenarios where Clipboard.GetImage() either crashes or doesn't render the supposedly successfully retrieved image. In this post I review some of the challenges and how you can work around the retrieving an ImageSource with an intermediary load of a bitmap in between to provide reliable image retrieval from the clipboard in WPF.
Read more...
January 19, 2025
- Maui, Hawaii
Once again I'm taking a look at the newish .NET release and how it compares to the previous release - this time .NET 9.0 from .NET 8.0. I'll run my simple load tests to compare performance and also discuss a number of anecdotes from running .NET 9.0 in production apps for the last couple of months.
Read more...
December 27, 2024
- Maui, Hawaii
I recently had another occasion to add Parallel.ForEachAsync() into an application to improve performance of an Http look up operation drastically. When I tweeted a note on X there was quite a bit of response, so I thought I follow up and discuss Parallel use in this use case and when it makes sense to use Parallel in applications.
Read more...
November 08, 2024
- Hood River, Oregon
There's no direct support in WPF to find the control that the mouse is hovering over in Items controls like the TabControl, so if you need to bring up context sensitive information like a context menu or tooltip it takes a little extra effort to get the correct item to work with in this case ContextMenuOpening.
Read more...
October 24, 2024
- Hood River, Oregon
I recently got a SnapDragon X Elite ARM device to play with and while I've been impressed with all things that work very well on it, one thing did not install easily: SQL Server. There's no ARM version of SQL Server and the x64 versions don't run on ARM devices. Docker images are also amd64 so that didn't work well either. Turns out you can use LocalDb onin emulation mode, but setting it up is anything but intuitive. In this post I discuss how to get SQL Server to run on a Windows ARM device.
Read more...
September 03, 2024
- Hood River, Oregon
Ever need to retrieve an ASP.NET application's hosting Urls? There are million ways to set these URLs but there's no easy fixed location where you can pick the addresses up from. Instead you have to go through a bit of a dance, and use one of two approaches depending on whether you need the addresses during startup or inside of a request.
Read more...
August 04, 2024
- Hood River, Oregon
Every once in while when I publish a NuGet package and then try to use the published package in another project I end up with a situation where the new package simply is not recognized. Most of the time it shows up after a few minutes, but on more than a few occasions I've stuck waiting for quite a while waiting for the package cache to refresh. Luckily there's a way to nuke the cache and force Nuget to re-read local packages and while that is the nuclear option that requires downloading a lot of packages it works to make your project compile - right now!
Read more...
July 29, 2024
- Hood River, Oregon
PlantUML is a Web based diagramming markup language that can be used to create diagrams using text descriptions that are rendered into images via a PlantUML server. In this post I describe how you can integrate PlantUML image rendering into your .NET application, specifically from a Markdown rendering perspective as Markdown documents are the most common mechanism that PlantUML output is delivered.
Read more...
July 25, 2024
- Hood River, Oregon
Sometimes it's useful to call async methods and be able to stop waiting after a given timeout period. Unfortunately there's no native support on Task to provide this. In this short post I show how you can simulate timeouts and provide a couple of helper methods to make the process generically available.
Read more...
July 22, 2024
- Hood River, Oregon
The WebView2 control's NavigateToString() method has a limit for the string size of 2mb, which can be a problem especially for HTML pages with embedded content. In this post I'll describe how this problem can show up and show a couple of ways to work around the issue.
Read more...
July 18, 2024
- Hood River, Oregon
If you deal with old .NET library code that is sprinkled with some Windows specific code in places you've likely run into places where the Windows specific code is throwing up unwanted compiler warnings. Sometimes that matters, but often times these warnings are annoyances as these methods are highly unlikely to get called from x-platform code. In this post I describe some annoyances, how you can work around them and eventually fix the issues without throwing everything out the window.
Read more...
June 13, 2024
- Hood River, Oregon
I'm tired of trying to format versions for user facing interfaces after fumbling with it again and again. In this short post I show a small helper extension method that lets you configure how to form user friendly version strings to display to end users.
Read more...
May 26, 2024
- Hood River, Oregon
Ran into an old legacy application recently that required that attached data was preformatted to Mime Base64 which I never even heard of before. Turns out it's a 'url-safe' version of base64 that replaces certain characters that can be present in base64 with 'safe' characters. In this short post I show a small helper that handles several Base64 Mime operations.
Read more...
May 03, 2024
- Hood River, Oregon
If you're like me, you've probably cursed the Windows Start menu from time to time, when it's either very slow to pop up, or in some instances fails to pop up at all when you press the Windows key. This simple tip can drastically improve performance of your Windows Start Menu by simply disabling Web search.
Read more...
April 28, 2024
- Hood River, Oregon
I recently ran into a major failure related to Shadow Copying for an ASP.NET Web app on IIS which was caused by corruption of the Shadow Copy directories. The app starts with the dreaded white ANCM Error page and event log entries that point at missing application folders. It turns out that this is caused by interference of multiple applications using the same shadow copy folder. In this post I describe the problem and how to work around it.
Read more...
March 26, 2024
- Maui, Hawaii
In this post I describe how to use the Microsoft WebView2 control to automate HTML to PDF generation generically for any kind of Windows application, including services. We'll look at the WebView and it's printing functionality and some of the intricacies that are involved in hosting the WebView control outside of a desktop application context to provide unattended mode even in service context.
Read more...
March 08, 2024
- Maui, Hawaii
When I set up a new machine I usually use a small ASP.NET test project to get a feel of performance of the machine and when that happens I also take a moment to compare performance across recent versions of .NET to see how things are improving - and improved they have. Both due to the new hardware I'm using but also ASP.NET continues to bump up performance in every new version that comes out. In this post I describe a simple project with minimal do nothing requests to test the ASP,.NET pipeline locally and how to test these request as well as discussing the results.
Read more...
February 20, 2024
- Maui, Hawaii
Some time ago I wrote about accessing raw request body content in ASP.NET Core which ended up being one of the most popular posts on this blog. But I failed to mention one major caveat: By default Request.Body can only be read once. In this post I discuss why frequently when you need raw Request.Body access you actually need to read the body more than once, and you can enable that functionality and deal with the caveats of doing so.
Read more...
January 10, 2024
- Maui, Hawaii
For some unfathomable reason, Windows 11 has removed the Sharing Tab on the Explorer Properties Context menu by default. The Sharing Tab allows you to shared folders and drives for remote access. In this post I discuss how to get the Sharing Tab back and also touch on how to make sure your machine can actually accept remote connections so you can share your folders and drives.
Read more...
January 03, 2024
- Maui, Hawaii
The WPF Image control and its ImageSource property can be problematic if you are loading a lot of images in a list. Depending on where you load images from, and how, you can very easily get bogged down with slow, blocking load operations, and memory leaks when the controls are released. In this post I describe a couple of specific problems I ran into loading a sizable list of images from files and show a few ways how to avoid the potential pitfalls related to ImageSource peculiarities.
Read more...
December 21, 2023
- Maui, Hawaii
Image Generation AIs are proving to be very good at creating images that can be used for all sorts of purposes. In this article I discuss how you can integrate image generation right into your own .NET applications using the OpenAI REST API. In addition I'll show how you can integrated this functionality into a larger application and discuss some general thoughts on image AI usage based on some of the experiences from a developer/non-designer user perspective.
Read more...
November 27, 2023
- Maui, Hawaii
Did you ever need to embed a Web Server into a non-Web application? In this post I describe how you can use host ASP.NET in a non-Web application and specifically in a WPF desktop app. What do you need, how is it different and some of the issues that you need to consider if you want to use ASP.NET in your non-Web applications.
Read more...
November 03, 2023
- Maui, Hawaii
If you have an application that generically allows you to edit and save files, you might on rare occasions need to save files in locations that where a regular user account does not have permissions to save. Rather than failing wouldn't it be nice to let the user know and optionally allow saving with elevated permissions? In this post I describe the workflow and implementation on how to do just that.
Read more...
October 31, 2023
- Maui, Hawaii
I've been struggling with rare WebView initialization errors in one of my applications, that have been difficult to debug and track down. After a lot of trial and error I discovered that the problem is related to WebView Environment instantiations that might be stepping on each other. In this post I describe the problem and a solution that involves creating a single WebView Environment and reusing it for all WebView initialization.
Read more...
October 02, 2023
- Hood River, Oregon
.NET Core has sophisticated policies that allows your applications that are compiled to specific versions of the .NET Runtime can roll forward to newer versions. You can specify what part of the version to roll forward and that generally works well, except for preview releases which require an extra step.
Read more...
September 19, 2023
- Hood River, Oregon
Running on IIS locally is pretty rare, but if for some odd reason you decide to run IIS locally on your dev machine you might find yourself getting a 500.19 error which relates to an issue in the web.config configuration. The solution is simple enough: Make sure the ASP.NET Core Hosting Module is installed. In this post I describe in more detail what the problem is and why you need a seemingly superfluous extra install to get IIS and ASP.NET Core to cooperate on local dev machine.
Read more...
September 11, 2023
- Hood River, Oregon
I've run into this problem a few times: I install a new Mac OS and then install the .NET SDK. A bit later I install a dotnet tool using `dotnet tool install -g` and then try to run it, only to find out that the SDK is not able find it. This post is a note to self on how to fix the pathing for .NET tools to be found correctly and to be able to run your dotnet tools.
Read more...
August 15, 2023
- Hood River, Oregon
ASP.NET Core doesn't have a Server.MapPath() method as classic ASP.NET had, and getting at the root path in Core is a little bit more involved than in those older versions. In this post I describe how to find the application Content and Web root folders and describe a MapPath() helper that simulates the old behavior.
Read more...
August 08, 2023
- Hood River, Oregon
Statusbar controls are boring, but because of the way that they are used there are a number of caveats like ensuring the UI updates even in linear code, allowing for timeouts of status messages and resetting to default, and to provide some visual clues to draw attention to the status messages displayed. In this post I talk about a custom status bar control and helper that make it super easy to use a new status bar control or attach additional functionality to an existing status bar.
Read more...
June 21, 2023
- Hood River, Oregon
I've recently moved my Markdown Monster Desktop Application to .NET 7.0 and I had to make a decision on how to get the Runtime installed or packaged with my application. In this post I review the different deployment modes, the plus's and cons and the solution I ended up with which was to build a custom install wrapper that can check and install the runtime if not already present from an Installer or interactively.,
Read more...
May 29, 2023
- Hood River, Oregon
Recent .NET Core versions have changed how .NET Core Library projects output dependencies into the build folder. The new behavior doesn't output depdencies, unlike full framework .NET projects which always automatically dumped dependencies into the build output folder. This isn't a common requirement, but when you need it, the options are sufficiently obscure and this post discusses how you can make your dependencies output into the build folder
Read more...
May 17, 2023
- Hood River, Oregon
Two factor authentication using Authenticator apps is getting more popular. One advantage of Authenticator 2FA is that you don't need to use a service nor do users have to provide additional bits of personal information. It's easy to implement, doesn't cost anything and also very secure as it uses one-time codes that can't easily be corrupted short of physical take over of a device. In this article I describe how Authenticator based 2FA works in the context of an application without using ASP.NET Identity.
Read more...
May 08, 2023
- Maui, Hawaii
ASP.NET Core applications that run on IIS as InProcess output an Server name for IIS into the HTTP headers. If you want to remove the server header, you'll find that the process for IIS is different than for the internally created Kestrel header and you can't use the same approach to remove the header as with Kestrel applications. In this post I discuss why the header behaves differently in IIS and how to remove it regardless of ASP.NET version.
Read more...
April 30, 2023
- Maui, Hawaii
As a developer, you're likely to occasionally send an email with attachments that are either code or binary executable files either as straight files or in a zipped up collection of code or binary files. You'll find that you can't actually send certain types of files or even files embedded in archives and even encrypted archives as most mail servers these days scan file content both before sending and when receiving email. In this post I discuss what works and what doesn't and how you can work around those files that don't work. It ain't pretty...
Read more...
April 21, 2023
- Maui, Hawaii
By default .NET SDK project dump their final build output into a deeply nested folder structure that describes the build configuration, target, platform and sometimes additional package folders. While that's useful especially for multi-targeted projects. Sometimes you just want your output to go to specific folder without all that noise. In this short post I show you what you need to set in your project file to put your files exactly where you tell them to,
Read more...
April 17, 2023
- Maui, Hawaii
If you've build mobile Web applications that need to run on iOS Safari and on an iPhone you might have run into the problem of input fields 'auto-zooming' the display when the input field and popup keyboard get focus. The view zooms and doesn't return back to the unzoomed even after exiting the input field. In this post I describe why this happens in some scenarios, and a couple of ways you can work around this annoying iOS Web browser behavior.
Read more...
April 10, 2023
- Maui, Hawaii
Using Application Insights with desktop applications isn't the most obvious operation, as App Insights has been primarily designed as a tool for providing logging, statitics and exception report for Web based applications. However, with a little bit of reworking it's actually quite straight forward to use Application Insights with Desktop applications and in this post I show you how I integrate App Insights in my WPF applications.
Read more...
March 15, 2023
- Maui, Hawaii
WkHtmlToPdf is a commonly used tool to create PDF documents from HTML files or Urls. Unfortunately it's a bit cranky and one of the problems you can run into is that links that include URL encoding won't work in your output PDF. In this post I describe the problem and a hacky workaround to make broken PDF links work by hacking the HTML file prior to conversion.
Read more...
February 16, 2023
- Maui, Hawaii
When using async events, it's important to understand how events work when called asynchronously. Specifically if you need to interact with the event context for things like preventDefault(), cancelBubble() or returning values that determine completion state, you need to be careful as these may have no effect if called after an `await` call.
Read more...
February 09, 2023
- Maui, Hawaii
I learned something new today: there's a CSS `text-transform` style property that can be used to transform text automatically to upper, lower or capitalized case. No JavaScript contortions and it just works. In all my years doing Web dev I've not run into this property before, so I'm posting it here for others to find as well...
Read more...
February 06, 2023
- Maui, Hawaii
The native date picker in HTML is a bit of a pain to work with as it's overly simplistic in features and how you have to assign and retrieve values from it. It also isn't customizable so if you need to build custom behavior like a button date popup that doesn't show the input control, you're out of luck. In this post I discuss the challenges of the HTML date picker control, provide small component to make binding values easier, and provide an example on how to create a button only date picker both with plain JavaScript and as a small Vue component.
Read more...
February 02, 2023
- Maui, Hawaii
When writing out error information for a desktop application to a log whether local or to a telmetry engine, it's useful to get some idea of what hardware the app is running on. WPF applications in particular can have odd behaviors that are related to hardware acceleration, running inside of a VM or particular video drivers. In this short post I show how you can get very basic machine and GPU information that provides information on these basic system stats that can prove useful to trackdown rare hardware related issues.
Read more...
January 28, 2023
- Maui, Hawaii
Ran into a problem with Windows Audio not playing for MP3, WAV and other music files as well as some applications like Spotify. Any audio playback ended up resulting in an error related to an invalid encoder. Turns out the problem was an unexpected settings change. Here's the scoop.
Read more...
January 26, 2023
- Maui, Hawaii
HTML table column wrapping and truncating doesn't work like other HTML elements. Specifically if you want to keep table column content from wrapping via `overflow` or `white-space` wrapping settings you'll find that tables just laugh in your face. Here's a quick post that describes table wrapping and text truncation issues and the hacky workaround.
Read more...
January 05, 2023
- Maui, Hawaii
As of Git 2.36.2 Git has a new security feature that won't allow running Git commands until the folder the repository lives in is 'trusted'. This can be annoying, but it's relatively easy to fix. In this post I look at what causes the issue and show a number of ways that you can use to trust the repository to get on with life...
Read more...
December 06, 2022
- Maui, Hawaii
I recently switched to a single 4k monitor and had a need to quickly switch resolutions to avoid the UI hostile Windows Display Resolution widget in Settings. I ended up creating a small command line utility called SetResolution that lets you quickly and easily set a new Resolution, create profiles of resolutions to switch to.
Read more...
November 07, 2022
- Maui, Hawaii
If you're self-hosting ASP.NET Core applications on IIS and using WebDeploy to publish to the server, you've very likely run into the dreaded locked file problem on the server. In this post I show you how you can work around locking problems with the base WebDeploy configuration and by using a new experimental feature in ASP.NET 6.0 to Shadow Copy deploy binaries. As a bonus this post also describes setting up and using Web Deploy in some detail.
Read more...