Rick Strahl's Weblog
Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact
•
Articles
•
Products
•
Support
•
Advertise
Sponsored by:
West Wind
WebSurge
- Rest Client and Http Load Testing for Windows
advertise here
Recent Weblog Posts
Archives
March, 2025 (3)
February, 2025 (2)
January, 2025 (1)
December, 2024 (1)
November, 2024 (1)
October, 2024 (1)
September, 2024 (1)
August, 2024 (1)
July, 2024 (4)
June, 2024 (1)
May, 2024 (2)
April, 2024 (1)
March, 2024 (2)
Categories
ASP.NET (327)
.NET (184)
Windows (80)
JavaScript (73)
jQuery (61)
Visual Studio (54)
WPF (49)
IIS (48)
Csharp (48)
HTML (48)
AJAX (45)
ASP.NET (33)
Localization (32)
LINQ (30)
WCF (28)
MVC (26)
Personal (25)
Security (23)
HTML5 (23)
FoxPro (22)
CSS (22)
C# (20)
Angular (20)
Web Services (19)
Web Api (16)
COM (16)
ADO.NET (15)
Vista (11)
Sql Server (11)
XML (11)
WebView (10)
HTTP (10)
IIS7 (10)
Markdown (9)
Microsoft AJAX (8)
IIS7 (7)
West Wind Ajax Toolkit (7)
Web Connection (7)
NuGet (6)
Markdown Monster (6)
Entity Framework (6)
Html Help Builder (5)
Live Writer (5)
Internet Explorer (5)
C++ (5)
ASPNET5 (5)
Mobile (5)
SignalR (5)
Software Development (5)
Web (5)
OWIN (5)
WinForms (5)
Westwind.Globalization (4)
Source Control (4)
Silverlight (4)
Cordova (4)
Conferences (3)
DataBinding (3)
ASP.NET Core (3)
Help Builder (3)
ISV (3)
LetsEncrypt (3)
Networking (3)
Office (3)
Opinion (3)
Razor (3)
Web Browser Control (3)
WebLog (3)
Web Development (2)
Visual Studio Code (2)
Tools (2)
Speaking (2)
RegEx (2)
RSS (2)
Linux (2)
Installation (2)
Bugs (2)
Help (2)
Dotnet (2)
.NET Standard (2)
Addins (2)
Deployment (2)
Authentication (2)
ASP.NET vNext (2)
ADO.NET (1)
Chocolatey (1)
Blazor (1)
Blogging (1)
Desktop (1)
Control Development (1)
Credit Card Processing (1)
Cross-Platform (1)
.NET ASP.NET (1)
.NET ASP.NET Windows (1)
Security (1)
Visual Studio (1)
ASP.NET IIS (1)
ASP.NET Markdown (1)
AI (1)
Angular JavaScript (1)
Dynamic Types (1)
Email (1)
CSharp Dotnet (1)
Git (1)
Graphics (1)
Hardware (1)
FireFox (1)
Flexbox (1)
IOS (1)
JSON (1)
Migration (1)
rxJs (1)
SEO (1)
RazorPages (1)
Musings (1)
Travel (1)
Typescript (1)
Testing (1)
Threading (1)
VS Code (1)
Web Deployment Projects (1)
Web Design (1)
Web Assembly (1)
WebSockets (1)
WebSurge (1)
WebBrowser (1)
WebDeploy (1)
WFH (1)
Windows-Terminal (1)
Windsurfing (1)
WPF Windows (1)
WSL (1)
wwHoverPanel (1)
Making Html Input Controls Truly ReadOnly
4 comments
March 14, 2025 - Maui, Hawaii
A discussion of how to show readonly controls in user interface and ensuring that they are not UI activated. This post discusses readonly and disabled behavior and how you can make readonly behave better if you choose to use it over disabled.
Accessing Windows Settings Dialogs from Code via Shell Commands
March 13, 2025 - 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.
Resolving Paths To Server Relative Paths in .NET Code
March 08, 2025 - 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.
Inline Confirmations in JavaScript UI
2 comments
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.
Retrieving Images from the Clipboard Reliably in WPF Revisited
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.
Comparing Raw ASP.NET Request Throughput across Versions: 8.0 to 9.0 Edition
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.
Back to Basics: Using the Parallel Library to Massively Boost Loop Performance
7 comments
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.
Getting the Current TabItem when the Tab is not selected in WPF
3 comments
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.
Using SQL Server on Windows ARM
13 comments
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.
Getting the ASP.NET Core Server Hosting Urls at Startup and in Requests
4 comments
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.
Nuking Local Nuget Package Sources to show newly Published Packages
1 comment
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!
Create a .NET PlantUML Markdown Render Extension
2 comments
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.
Back to Basics: Await a Task with a Timeout
8 comments
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.
Work around the WebView2 NavigateToString() 2mb Size Limit
3 comments
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.
Dealing with Platform Specific Classes and Methods in CrossPlatform .NET
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.
C# Version String Formatting
9 comments
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.
Mime Base64 is a Thing?
3 comments
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.
Speed up your Start Menu by disabling Web Search
2 comments
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.
ASP.NET Core Hosting Module with Shadow Copy Not Starting: Separate your Shadow Copy Folders!
4 comments
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.
Programmatic Html to PDF Generation using the WebView2 Control with .NET
9 comments
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.
Comparing Raw ASP.NET Request Throughput across Versions
2 comments
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.
Reading Raw ASP.NET Request.Body Multiple Times
4 comments
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.
Sharing Tab Missing in Windows 11 Folder Properties
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.
Working around the WPF ImageSource Blues
2 comments
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.
Integrating OpenAI Image Generation into a .NET Application
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.
Embedding a minimal ASP.NET Web Server into a Desktop Application
3 comments
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.
Save Files With Elevated Permissions on UnauthorizedAccessException
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.
Caching your WebView Environment to manage multiple WebView2 Controls
2 comments
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.
Rolling Forward to Major Versions in .NET
2 comments
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.
IIS Error 500.19 with ASP.NET Core Application
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.
Dotnet Tool Component not found on the Mac
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.
Map Physical Paths with an HttpContext.MapPath() Extension Method in ASP.NET
1 comment
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.
A WPF Statusbar Control
1 comment
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.
Getting the .NET Desktop Runtime Installed with a Custom Runtime Checker and Installer
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.,
Getting .NET Library Projects to Output Dependent Assemblies
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
Implementing Two-Factor Auth using an Authenticator App in ASP.NET
7 comments
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.
Removing the IIS Server Request Header from ASP.NET Core Apps (any version)
4 comments
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.
Sending and Receiving GMail Email Attachments that contain Code or Binaries
5 comments
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...
Setting an Absolute Output Path for .NET SDK Projects
1 comment
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,
Preventing iOS Textbox Auto Zooming and ViewPort Sizing
6 comments
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.
Using Application Insights in .NET Desktop Applications
2 comments
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.
WkHtmlToPdf: Dealing with broken Url Encoded and Extended Character Links
5 comments
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.
Async Event Methods and preventDefault() in JavaScript
3 comments
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.
UpperCase Styling via CSS and text-transform
7 comments
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...
A Button Only Date Picker and JavaScript Date Control Binding
5 comments
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.
Basic Windows Machine Hardware information from WMI for Exception Logging from .NET
4 comments
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.
Windows Audio Encoding Failure after Settings Change
2 comments
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.
HTML Table Cell Overflow Handling
1 comment
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.
Fix that damn Git Unsafe Repository
10 comments
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...
SetResolution: Setting Windows Display Resolution from the Terminal
1 comment
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.
Avoid WebDeploy Locking Errors to IIS with Shadow Copy for ASP.NET Core Apps
6 comments
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.
HSTS: Fix automatic re-routing of http:// to https:// on localhost in Web Browsers
4 comments
October 24, 2022 - Maui, Hawaii
If you're doing local Web develop with multiple development tools you've probably run into a problem where you end up not being able to access a local site via unsecured `http://` requests and automatically get redirected to `https://` no matter what you try. If you don't have a certificate set up for the site you may not even be able to access the site at all. Turns out this usually is due to HSTS which is a nasty little bugger of a security protocol that is applied universally to a domain even in applications that don't use HSTS. In this post I discuss how HSTS works and why it can be a problem for local development as well as how to clear out the HSTS cache or avoid using it locally.
Testing HttpRequest.Form Variables in Unit Tests for ASP.NET Core Components
September 18, 2022 - Hood River, Oregon
Here's a quick post that shows how to create a testable HttpRequest.Form collection so you can test form variables in a unit test.
Referencing a Local Private NuGet Package in your Solution
5 comments
September 11, 2022 - Hood River, Oregon
I recently needed to add a local reference to my project and I couldn't quite figure out the best way to do it in a transparent way to consumers of the repository, so that they wouldn't have to explicitly configure additional build settings in order to find dependencies. In this post I discuss how to add local references or use a local Nuget source to add non-public packages to your projects without explicit package feed configuration.
Keeping Content Out of the Publish Folder for WebDeploy
5 comments
August 24, 2022 - Hood River, Oregon
Sometimes when you publish a project to the server, you need to keep certain content that's part of your local development from publishing to the server. You can control how MSBuild publishing handles file output in a myriad of ways and it can be confusing if you don't know the exact settings you need to set for each scenario. In this post I discuss various options available include using the project item settings and the options in the pubxml file along with some commentary on when you might need this functionality.
Mapping Multiple Static File Folders in ASP.NET Core
3 comments
August 23, 2022 - Hood River, Oregon
Recently I needed to map an external folder as a 'virtual' directory in an ASP.NET Core application to include externally added content into the main Web application. ASP.NET Core's Static File Middleware provides easy mapping of a folder for static file serving, but it's not so obvious to add additional folders for static file serving. In this post I'll show you how to do this and a few other thoughts around this topic most common when physically hosting on a server.
ASP.NET Core MVC Views not Resolving Partial Views outside of the default ControllerContext
3 comments
August 08, 2022 - Hood River, Oregon
I recently ran into a problem with ASP.NET Core MVC views where rendering a Parent View in a Controller Context other than the originally designed context won't find Child Views that are referenced with no or local or relative paths. It turns out that ASP.NET Core MVC does not resolve local View paths as expected when rendering a View from a different ControllerContext instead using the current controller's context paths, rather than the view relative paths. In this post I describe why this can be a problem and several ways to work around this problem.
Fighting WebView2 Visibility on Initialization
11 comments
July 14, 2022 - Hood River, Oregon
The WebView2 control has a clever 'feature' that doesn't fully initialize the WebView control if it's not UI visible. While this can save resources in some scenarios it can also make for some very annoying behavior that causes startup timing and flickering issues. In this post I describe a few scenarios where this initial visibility delay loading can cause issues and show a trick you can use to get around it if this 'feature' causes a problem.
Back to Basics: Custom HTTP Response Header Manipulation in ASP.NET Core
1 comment
July 07, 2022 - Hood River, Oregon
HTTP Headers are a core part of the HTTP protocol and while applications rarely need to deal with them, when you need to set them - especially globally - ASP.NET Core doesn't have an obvious, built-in way to add headers to every request. In this back to basics post I describe what HTTP header, why you might set them and show how to set them as part of individual requests as well as globally for every request in your site.
Back to Basics: Rendering Razor Views to String in ASP.NET Core
12 comments
June 21, 2022 - Hood River, Oregon
Rendering a Razor View to string can be very useful to create string output from Views that you can capture and then use for things like Email confirmations or saved receipts that can be accessed 'offline' from the application. In this post I show you how to capture views to string and a few caveats you have to watch out for if you're generating self-contained HTML output to string.
Runtime C# Code Compilation Revisited for Roslyn
15 comments
June 07, 2022 - Maui Time, Hawaii
Recently I needed to update my scripting tools that are integrated into Markdown Monster, in order to support .NET Core. The old CodeDom compiler APIs I'd been using as part of my `Westwind.Scripting` library aren't supported in Core and so I ended up updating to the newer Roslyn CodeAnalysis APIs. In this post I discuss how the Roslyn compilation APIs work, and how I built and updated the Westwind.Scripting library to provide an easy to use wrapper around these tools.
Async and Async Void Event Handling in WPF
9 comments
April 22, 2022 - Maui Time, Hawaii
When running WPF and WinForms applications with async operations, I've run into a number of issues with event handling 'hanging' the UI thread in unexpected ways, where the UI hangs until the mouse is moved or a key is pressed. A lot of times these issues are associated with events that fire async code, and in this post I take closer look at one scenario that can cause these hang ups along with a workaround that has proven useful in a number of occasions for me.
Use CSS.escape() to escape QuerySelectorAll()
April 10, 2022 - Maui Time, Hawaii
Ran into an issue recently where a querySelector operation was failing in document link navigation when navigating hashes. There are a few issues at work when using Hash navigation but one issue i didn't expect to run into was a naming conflict of a hash tag that interfered with CSS operators. Turns out there's an easy solution around with with CSS.escape - if you can make the connection. In this post I talk about the problem how it might show up and how to fix it.
Combining Bearer Token and Cookie Authentication in ASP.NET
15 comments
March 29, 2022 - Maui, Hawaii
In some situations you might need to use both Bearer Token and Cookie Authentication in a single application. In this post I look at a few scenarios where this is required and show how to configure your Authentication to let you access your site with either authentication scheme.
Creating a Static Web Content Project for Publishing with WebDeploy
2 comments
March 03, 2022 - Maui, Hawaii
Static content projects are more and more common and if you need to publish directly to an IIS Web Server using WebDeploy is one of the options you have. If you're building .NET projects there are many ways to publish projects from Visual Studio and the `dotnet` CLI. Unfortunately there currently is no .NET/Visual Studio project type that works out of the box for Static Site content - if you need to use WebDeploy. In this post I discuss how to hack a .NET Web project to work with static content only.
Escaping Markdown Code Snippets and Inline Code as Markdown
February 16, 2022 - Maui, Hawaii
If you write Markdown for code related documentation it's not uncommon that you need to create code snippets or inline-code blocks that contain the Markdown code block delimiters namely the back tick. If you need to embed a Markdown code block as documentation in another code block or if an inline code block simply contains a ` you run into rendering problems. In this code I tackle escaping Markdown code for nested code blocks and escaping the pesky back tip character.
West Wind WebSurge 2.0 is here
5 comments
February 01, 2022 - Maui, Hawaii
I've just released West Wind WebSurge 2.0. WebSurge is a REST Client and Load Testing tool for Windows and in this post I provide a short overview, a link to a new YouTube Getting Started video, and some background on this release
Fixing Windows Control Focus on Toolbar and Menu Controls
2 comments
January 25, 2022 - Maui, Hawaii
You ever run into a problem in a Windows application where saving data off a Menu or Toolbar doesn't save the last changed value? Well, it's a pretty common problem in Windows Applications that's due to the fact that these controls don't change the active control focus which in turn can fail to update data binding from updating the underlying data source. In this post I go into detail on why this happens and describe a few workarounds.
Integrating Long Path Names in Windows Applications
6 comments
January 03, 2022 - Maui, Hawaii
Long Path Names in Windows are a pain in the butt, but Windows 10 recently starting adding better support for Long Paths in Version 1607+ which for now has to be enabled explicitly. It also requires an application configuration switch in the manifest file. As nice as that support is, it doesn't solve all problems especially when integrating with other components or external applications that don't support long paths. In this post I describe what works, what doesn't and a few hacks to make most things work.
Connection Failures with Microsoft.Data.SqlClient 4 and later
17 comments
December 07, 2021 - Maui, Hawaii
After a recent update to `Microsoft.Data.SqlClient` version `4.0.0.0` I ended up not being able to connect to any of my SQL Server databases. Turns out Microsoft has made some default settings changes in the updated provider and these settings are likely going to break connections.
Windows Authentication with HttpClient
15 comments
November 27, 2021 - Maui, Hawaii
In this short post I review how to use HttpClient with Windows Authentication security using Negotiate or NTLM authentication schemes, which oddly is not documented in the official documentation for the `CredentialCache` class used to handle authentication header generation in HttpClient.
Back to Basics: Add an ASP.NET Runtime Information Startup Banner
1 comment
November 09, 2021 - Maui, Hawaii
In almost every .NET Core Console application I end up adding a startup banner with some basic runtime information so I can see at a glance what environment I'm running in. I also add the URLs and any other application specific information that might be useful. In this short post I show a few things I display and how I reuse this functionality since it practically goes into every application I run.
Discovering new C# String Pattern Matching Features
4 comments
November 04, 2021 - Maui, Hawaii
I admit it: I haven't been using the new C# pattern matching features a lot, but every once in a while ReSharper smacks me in the head and points out a good pattern that not only makes the code more compact, but also makes it more readable. In this post I talk about a few patterns that help with null and string casting and with comparing values in a more natural way.
WebView2 Flashing when changing TabControl Tabs
3 comments
October 04, 2021 - Hood River, Oregon
I've been running into major issues with the WebView control and TabControls in WPF where switching between tabs that contain WebView controls causes a very annoying white flash. In this post I demonstrate the problem and provide an arcane fix that works around this frustrating issue.
Launching Visual Studio Code cleanly from a .NET Application
September 03, 2021 - Hood River, Oregon
Visual Studio Code has become the mainstay editor for many developers. If you have developer focused applications and you need to externally display text or code content, it would be very useful to pop open VS Code to display external text/code content. This sounds simple enough, but Code both on Windows and Mac has some peculiar launch behaviors that make this a little more tricky than you might think, especially if you need to make sure that you can do it across platforms.
Using the WebView control to capture HTTP Request Content
1 comment
August 18, 2021 - Hood River, Oregon
Need to capture requests when navigating the new Edge WebView2 control? The control supports this but the way that you do this is a little less obvious than you might be used to from other browser controls. Here's how to do it.
WebView and Modal Dialogs in WPF Async Code
1 comment
August 16, 2021 - Hood River, Oregon
Another day another problem with the WebView control - this time dealing with certain Windows dialogs crashing the WebView control and making it unresponsive so that the control has to be reloaded or - more commonly the application has to be restarted.
Markdown Monster 2.0 is here
July 22, 2021 - Hood River, Oregon
It's been a long slow road but Markdown Monster 2.0 is finally here. This update features a number of internal updates to facilitate future development improvements. In this post I go over some of the changes in the new release and some of the challenges that had to be worked through to get here.
Thoughts on Async/Await Conversion in a Desktop App
11 comments
July 07, 2021 - Hood River, Oregon
I spent the last month or so working through Markdown Monster's code to switch from mostly sync code to async code. This change was forced on me by an Async Cascade triggered by a third party dependency of a component (the WebView2 control) and ended up requiring massive changes throughout the app. In this post I go over some of the issues I ran into converting from sync to async along with some thoughts on the pitfalls.
Locked Files When Publishing .NET Core Apps to IIS with WebDeploy
6 comments
June 20, 2021 - Hood River, Oregon
When using Visual Studio's Publish Web Site feature with ASP.NET Core you may get frustrating errors when publishing to already running sites as files on the server are locked and can't be updated until the site is shutdown. Turns out the default settings don't unload the application before publising, but there's a simple solution to unload before publishing and the restart the application.
Running .NET Core Apps on a Framework other than Compiled Version?
6 comments
June 15, 2021 - Hood River, Oregon
I get asked frequently about whether a lower version of .NET Core will run on a machine that only has a more recent version of the .NET Core runtime installed. The short answer is 'No it won't run' but there are a few nuances to this simple answer.
WebView2 Home and End Key Problems inside of WPF TabControl Containers
2 comments
May 25, 2021 - Hood River, Oregon
Another day another WebView2 quirk to work around: This time running into issues with the WebView2 not processing Home and End keys properly as they are being hijacked by a parent TabControl and its TabNavigation keystroke handling.
Async/Await Calls Gotcha with the CSharp ? Null Propagator
9 comments
May 15, 2021 - Hood River, Oregon
Null propagation in C# allows for short circuiting of void method calls, but when using result-less `await` async calls, this behavior works decidedly different, resulting in null exception runtime errors. While this behavior makes sense when you break down the command, it's certainly not obvious. In this post I break down the how and why of the failure and how to work around it.
Taking down the Markdown Monster Source Code
May 05, 2021 - Hood River, Oregon
With a heavy heart and a lot of hand wringing, I decided last week to take down the Markdown Monster source code from the public GitHub repository due to rampant abuse of the code to get around licensing restrictions. In this post I give some insight on why I made this decision and provide some general thoughts around the state of software development for software tools.
WebView2: Forwarding Alt Keys to a Host WPF Window
April 15, 2021 - Maui, Hawaii
I've been puzzling over how to reliably integrate keyboard forwarding from the WebView2 control into WPF host forms. Unlike the IE WebBrowser control the WebView2 doesn't automatically forward Alt keys to the host form so special handling is required. In this post I describe why this is a problem and show the workaround to make this work.
LiveReloadServer - A Generic Local Static Web Server with Live Reload based on .NET
3 comments
March 23, 2021 - Maui, Hawaii
I've released v1.0 of my LiveReload Web Server which is a local static file Web server that includes support for LiveReload, plus some optional dynamic features for rendering self-contained RazorPages and Markdown content. This Dotnet Tool is fast, easy to use and includes a host of convenience features that try to make the process of working with local Web content quicker and easier.
Role based JWT Tokens in ASP.NET Core APIs
26 comments
March 09, 2021 - Maui, Hawaii
ASP.NET Core Authentication and Authorization continues to be the most filddly part of the ASP.NET Core eco system and today I ran into a problem to properly configure JWT Tokens with Roles. As I had a hard time finding the information I needed in one place and instead ended up with some outdated information, I'm writing up a post to hopefully put all the basic bits into this single post.
Opening an Admin Windows Terminal from Visual Studio
1 comment
February 04, 2021 - Maui, Hawaii
Opening Windows Terminal from another application is a bit of a pain. In particular I wanted to open Windows Terminal as an External Tool from Visual Studio and found it wasn't as easy as referencing the `wt.exe` executable. Opening as an Administrator adds additional complexity. In this post I'll talk about the use case of an External Tools and the settings to launch both a regular and admin Windows Terminal instance from External Tools.
Chromium WebView2 Control and .NET to JavaScript Interop - Part 2
32 comments
January 26, 2021 - Maui, Hawaii
In part 2 of this post series I take a look at how to use the new Chromium WebView2 to interact with the DOM document and interoperate between .NET and JavaScript, both calling into JavaScript from .NET, and calling into .NET from Javascript
Taking the new Chromium WebView2 Control for a Spin in .NET - Part 1
45 comments
January 14, 2021 - Maui, Hawaii
This is Part 1 of a two part article that gives an overview of the new WebView2 Web browser control that is based on Edge Chromium. In Part 1 I look at the basics of what's needed to run the control using the WebView runtime, and how to get the control embedded and configured to use for basic HTML tasks. In Part 2 I look at interaction between the .NET application and WebBrowser and Javascript.
Blank Zero Values in .NET Number Format Strings
4 comments
January 05, 2021 - Maui, Hawaii
Recently needed a way to display a set of numbers in a WPF List display that required that values with a value of `0` display blank - using no explicit code or model changes. I learnt something new today: There's actually a way to use C# format strings to format numbers separately for positive, negative and zero values. Here's how that works.
Watch out for .NET Core Runtime Bitness for IIS Installs
2 comments
November 25, 2020 - Maui, Hawaii
I recently ran into a snag with one of the my Windows Server installs of an upgraded .NET Core 5.0 application. It turns out I didn't install .NET Core 5.0 correctly because I made some bad assumptions of what I needed to install to run my application, even though it previously ran on .NET Core 3.1. Here's more detail on what the failure looks like and how to properly install .NET Core 5.0.
Upgrading several of my Applications and Libraries to .NET 5.0
2 comments
November 24, 2020 - Maui, Hawaii
Over the last week I spent some time upgrading several .NET Core Web applications and libraries from .NET Core 3.1 to .NET 5.0. I'm happy to say that this was always a non-event as the process went very smooth for once. In this post I'll talk about what I found and also offer some commentary why we should celebrate this update and push Microsoft to continue along this path.
PC and Mac with single Mouse and Keyboard Setup on Dual 4k Screens
9 comments
October 15, 2020 - Maui, Hawaii
A little while back I posted a couple of pictures of my new desk setup using both a Windows Laptop (a 2019 Dell XPS) and a Macbook Pro (2016) along with two 4k displays. I'm also using a single Logitech Mouse and Keyboard combination to control both machines and quite a few people were asking about how this works. So I decided to write a quick review of my setup here to give a few more details that are hard to give in a Twitter conversation.
Window Activation Headaches in WPF
7 comments
October 12, 2020 - Maui, Hawaii
Ran into a problem with properly activating a WPF when launching from Explorer and indirectly trying to activate an already running instance 'from within itself'. It seems simple, but windows focus-stealing restrictions can cause problems with actually getting focus into an application window. Here's how.
Creating Custom .NET Project Types with .NET CLI Project Templates
7 comments
October 05, 2020 - Maui, Hawaii
Custom project templates can be extremely useful in quickly creating new projects especially for extensible applications. They're also great for creating specialized setups to make it quicker to hit the ground running. With the .NET SDK tooling new project templates are now easy to create and this post takes you through the process.
Wrestling with Clipboard Images in WPF
3 comments
September 16, 2020 - Maui, Hawaii
Retrieving images from the clipboard with WPF seems so simple, but once you get into it you'll find that there are lots of problems with reliable image retrieval that works for all images. In this post I talk about the different issues you're likely to run into and one hacky but flexible solution to better image support by selectively sniffing image formats and using different clipboard retrievals based on the image format.
Don't get burned by missing await Calls for Async Code in ASP.NET Core Middleware
11 comments
September 14, 2020 - Maui, Hawaii
I recently got burned in an upgraded ASP.NET Core server application where a missing `await` statement caused wildly inconsistent and puzzling output failures. While a simple thing to avoid, once introduced it's possible to live with this error for some time before it manifests. In this post I show a scenario where a missing `await` was causing infrequent HTTP response errors, even though the client apparently receives a valid response.
Using .NET Core Tools to Create Reusable and Shareable Tools & Apps
7 comments
August 05, 2020 - Maui, Hawaii
Dotnet Tools offer a simple way to create, publish and consume what are essentially .NET Core applications that can be published and shared using the existing NuGet infrastructure for packaging and distribution. It's y quick and easy to build tools that you can share either publicly or privately. In this article I make a case for why you might use or build a Dotnet Tool and show how create, build, publish and consume Dotnet tools as well as showing some examples of useful tools I've build and published.
Using the brightness() CSS Filter to generically highlight Content
3 comments
July 28, 2020 - Maui, Hawaii
Filters are not new in CSS, but their often overlooked for providing some useful generic behaviors for things like hover styling or nice background effects. In this post I discuss how to use the brightness() filter to create a generic button hover behavior and also briefly discuss the newish `backdrop-filter` property.
Excluding Files and Folders in Visual Studio Web Site Project
11 comments
July 25, 2020 - Maui, Hawaii
I still use Web Site projects frequently for purely static Web sites that don't require a proper build process where 'DevOps' of any kind is overkill. Invariably when using Web site projects though, I end up requiring that 1 or 2 files are excluded on publishing and every time I do I spent a while trying to find the information how to do that in the `.pubxml` file. Well no more - I'm writing it down this time.
Handling SPA Fallback Paths in a Generic ASP.NET Core Server
6 comments
July 12, 2020 - Maui, Hawaii
When building ASP.NET Core backends for SPA applications one thing that you have to worry about is how to handle client side routes that end up being fired against the server through external or reloaded links. While ASp.NET Core has built-in support for this if you build a generic Web server, you might need a little more control on how to handle the Fallback routing functionality. Here's how.
A .NET Color Console Helper
7 comments
July 10, 2020 - Maui, Hawaii
In this short post I'll discuss a small Console helper class I've been using to make it easier and more consistent to use colors with the .NET Console command. The .NET Console support colors easily enough, but switching colors and resetting them can be a bit tedious, so these helpers make working with color a bit easier.
Mirror your iOS Device Screen on Windows with the free 5KPlayer
5 comments
June 26, 2020 - Maui, Hawaii
Apple doesn't exactly make it easy to use iOS devices on Windows and one complication is how you can cast your iOS device to a Windows screen. This is useful for presentations or screen captures that I often do and in the past i've gone through a number of shady tools that have come and gone. Recently ran into 5KPlayer which is a nice video player that as a bonus acts as an AirPlay server and makes short work of casting iOS content to Windows
Using Angular's Live Reload Web Server to Refresh Pages on a Phone
3 comments
June 23, 2020 - Maui, Hawaii
Live Reload is now common for client side application development and it has become ubiquitous for Web development. But setting up Live Reload to work on a phone is not quite so obvious. In this post I'll walk you through what you need to do to get Live Reload to work on a mobile device for more productive on-device execution.
Adding Additional Mime Mappings to the Static File Provider
1 comment
June 12, 2020 - Maui, Hawaii
If you're using the Static File Provider in ASP.NET Core you might need to add some additional extensions that are not handled by default. For example, if you host a Blazor site in your own application an additional mime mapping for `.dll` is required. Here how you can map extra extensions to the Static File middleware.
ASP.NET Core WebSockets and Application Lifetime Shutdown Events
1 comment
May 28, 2020 - Maui, Hawaii
WebSockets in ASP.NET Core are easy to use but due to the simple model it's easy to forget that socket requests are long lived and can linger for a long time in the background and that can cause problems when an application needs to shut down cleanly. Luckily there's an `IHostApplicationLifetime` interface available that allows hooking shutdown operations and that provides the necessary cancellation tokens to allow an WebSocket connection to be terminated in response to a shutdown event. This post shows how this works.
Fixing Adsense Injecting 'height: auto !important' into scrolled Containers
1 comment
May 25, 2020 - Maui, Hawaii
Ran into a weird issue today with AdSense in one of my older Web sites. I noticed that the site was not using the custom scrolling in containers that I've been using for years. Turns out Google's AdSense on this page is injecting some extra styling that changes the scroll behavior - and the way the entire page works. Here's what the problem is and how you can work around it.
Using WSL to Launch Several Bash Commands from an Application
4 comments
May 19, 2020 - Maui, Hawaii
Struggled today with launching WSL from a Windows application to automate an external build process. Turns out this was a lot harder than it should have been due to some quirks on how the `wsl.exe` and `bash.exe` are registered by the Windows Sub System for Linux.
Static Constructor Failures and Declaration Order
3 comments
May 04, 2020 - Maui, Hawaii
I ran into an ugly problem today with an application where nested static constructors where not doing the expected thing - failing to provide a value when one should be available. It turns out the issue has to do with constructor calls nesting and the order in which auto-initialized values are assigned.
Displaying Nested Child Objects in the Windows Forms Designer Property Grid
5 comments
April 06, 2020 - Maui, Hawaii
The Windows Forms designer sometimes feels very dumb - one of those times is when dealing with nested properties on a control which by default is not displayed as an expandable property that you can just dig into. Instead you have to do a bit of busy work using a TypeConverter to make it possible to create an expandable property in the designer. Here's how.
Content Injection with Response Rewriting in ASP.NET Core 3.x
3 comments
March 29, 2020 - Maui, Hawaii
If you're creating middleware components you might need at some point to inject content in the existing HTTP output stream in ASP.NET Core. In this post I discuss how to intercept Response output by using a customized stream, modify the data and update the final output generated, effectively providing response filtering.
Back to Basics: Rewriting a URL in ASP.NET Core
17 comments
March 13, 2020 - Maui, Hawaii
Sometimes in an application you need to take over the routing process with some custom processing that acts on an incoming URL and actually has to go to another URL. This can be a simple relinking task from old content to new, or it can be more complex where you access a specific URL on the public site that actually needs to be processed by another URL altogether.
Troubleshooting Windows Sleep Insomnia
7 comments
March 02, 2020 - Maui, Hawaii
Windows long has had problems making machines stay in Sleep mode. In this post I describe some of the problems and likely solution by using `powercfg.exe` to hunt down and disable devices that can wake the computer from sleep.
Working with IWebHostEnvironment and IHostingEnvironment in dual targeted ASP.NET Core Projects
2 comments
February 26, 2020 - Maui, Hawaii
In ASP.NET Core 3.x Microsoft introduced a new `IWebHostEnvironment` to replace the obsoleted `IHostingEnvironment`. While that works for top level applications this can cause some complications for multi-targeted libraries that need to support both .NET Core 2.x and 3.x. This post describes the problems and offers a few workarounds.
Null API Responses and HTTP 204 Results in ASP.NET Core
9 comments
February 24, 2020 - Maui, Hawaii
ASP.NET Core's default API handlers return an HTTP 204 response for null value results. This is meant to be a convenience feature, but if your calling API depends on a proper JSON response or an HTTP 200 result code, it can cause applications to break. In this post I'll describe why this can be a problem and how you can return proper JSON results for null values.
Deleting Problem Folders and Files on Windows: Could not find this Item Error
18 comments
February 10, 2020 - Maui, Hawaii
Ever have a problem not being able to delete a file or folder because the filename is invalid? You see it in Explorer, but you can't delete or move the file? Well I just ran into this issue and after some digging figured out that you use extended path syntax `\\?\` to get around some interesting naming and sizing issue with Windows path operations.
ASP.NET Core IIS InProcess Hosting Issue in .NET Core 3.1
16 comments
January 14, 2020 - Maui, Hawaii
Ran into a nasty little issue with a hosted ASP.NET Core 3.1 application where InProcess hosting was not working. It turns out I hit a regression bug in 3.1 that causes InProcess hosting to fail if there are certain dependencies.
A HighlightJs Copy Code Badge Component
7 comments
December 30, 2019 - Maui, Hawaii
In this post I describe a small, very specialized addon component for the HighlightJs Syntax highlighter that displays a badge that lets you copy the code snippet and displays the syntax language. The post covers how to use this simple component, and a look behind the scenes on how it works.
VSIX Installer Extension Manifest and Visual Studio Version Numbers
7 comments
December 18, 2019 - Maui, Hawaii
Ran into a problem with updating a Visual Studio extension today where the VSIX installer first failed to install for the latest version of Visual Studio and then failed to enable the option to install for that same version. Turns out it was related to incorrectly specifying the right version number for VS 2019 and in this post I show how to use the correct (and somewhat unexpected) version syntax.
Creating Angular Synchronous and Asynchronous Validators for Template Validation
3 comments
November 18, 2019 - Maui, Hawaii
Validations are a key feature of any business application and in Angular there's an infrastructure for building validators built in. A number of existing validators provide the basics but if you have custom business logic to process for validation you'll need to create custom Validators. In this post I describe how to create both sync and asycn Angular Validators for use in declarative forms.
FireFox, Windows Security and Kestrel on ASP.NET Core
2 comments
November 14, 2019 - Maui, Hawaii
Ran into issues today with Windows Authentication and FireFox in a ASP.NET Core application where auth was working with all browsers **except** for FireFox. Firefox would just throw up endless sequences of login dialogs or in some cases just show the default ASP.NET Core 'UnAuthenticated' dialog. Here's what this looks like and how to work around it.
Dynamically Loading Assemblies at Runtime in RazorPages
5 comments
November 05, 2019 - Maui, Hawaii
I've been working on some tools that create generic, standalone Web servers using ASP.NET Core, in various configurations. One of the versions I'm building also supports Razor Pages and while genericallly hosting Razor Pages out of a locally run folder, there are some complications that arise out of dynamic runtime compilation. In this post I look at how to dynamically load assemblies at runtime.
Windows Authentication and Account Caching on Web Browser Auto-Logins
5 comments
October 19, 2019 - Maui, Hawaii
If you're working with Windows authentication to access Windows or Active Directory groups be aware that there's a gotcha with newly added groups when users are automatically logged into the Web browser.
Serving ASP.NET Core Web Content from External Folders
5 comments
September 30, 2019 - Maui, Hawaii
ASP.NET Core makes it easy to create a new Web site, but by default the location of where the application runs and serves files from is pretty static and pinned to the startup folder of the application. In this post I discuss another usage scneario of building a generic local Web Server that can start serving files out of **any** folder.
Upgrading my AlbumViewer Sample Application to ASP.NET Core 3.0
7 comments
September 24, 2019 - Maui, Hawaii
.NET Core 3.0 is here and in this post I describe the process of updating an existing ASP.NET Core Angular API application to this latest release. For the most part the update process is very smooth with a few configuration changes required, but there are also a few gotchas that have bitten me and I'll cover those here.
Open Internet Settings Dialog directly on Windows
2 comments
September 10, 2019 - Maui, Hawaii
Windows is making it harder to find classic Control Panel windows and the Internet Settings dialog is no exception. The Networking options no longer have a link to it, so you have remember where to look for it. Here's a quick way to get to it.
Programmatically Opening Windows Terminal in a Specific Folder
7 comments
September 03, 2019 - Maui, Hawaii
The new Windows Terminal provides many cool new features and much improved Terminal performance which makes it very desirable to use even in its current preview state. However, unfortunately the Terminal currently lacks a command line interface to control startup, do if you want to externally launch a shell some workarounds are required to get it to start out of a specific folder.
WPF Window Closing Errors
2 comments
September 02, 2019 - Maui, Hawaii
I've recently had a large uptick of errors in my Markdown Monster logs that complain about `Cannot set Visibility to Visible or call Show, ShowDialog, Close, or WindowInteropHelper.EnsureHandle while a Window is closing`. This error can crop up with nested or parallel window closing operations, which might not always be obvious when they happen. I'll show some of the issues and the hacky by easy to implement work around.
Visual Studio 2019.2 and .NET 3.0 SDK Projects not Loading
August 21, 2019 - Maui, Hawaii
Recent upgrades to Visual Studio 2019.2 seem to have broken projects that use the 3.0 .NET SDK as Visual Studio is defaulting to a pre-3.0 version of the SDK tools and compilers. The end result is that projects even fail to load in Visual Studio. There are workarounds but ultimately this an issue that Microsoft needs to address better in future updates.
Uri.AbsoluteUri and UrlEncoding of Local File Urls
August 20, 2019 - Maui, Hawaii
Ran into an interesting problem with the Uri class and local file URLs today. The problem is that Urls were not properly Url encoding and decoding with the Url treated incorrectly. After a bit of experimenting it turns out that the way the file URL is created is critical to the Url parsing behavior of the Uri class.
Building a Live Reload Middleware Component for ASP.NET Core
13 comments
June 03, 2019 - Maui, Hawaii
In my last way I showed how to use Live Reload in ASP.NET Server side applications using a tool called BrowserSync. In this post I replace BrowserSync's functionality with a custom Live Reload Middleware component for ASP.NET Core that's more efficient and doesn't require installing and running a separate tool. I'll show how Live Reload works, and how to implement the component in some detail.
Live Reloading Server And Client Side ASP.NET Core Apps with BrowserSync
13 comments
May 18, 2019 - Maui, Hawaii
Client side live reloading is one of the most compelling features of client side JavaScript development. Instant updates of any code changes in the browser are a huge productivity booster - WYSIWYG on steroids. Unfortunately for ASP.NET Core server side code and MVC apps there aren't any comparable easy solutions. In this post I show how I use Browser Sync and `dotnet watch` in combination to provide live reloading for both server and client side changes.
Accessing RouteData in an ASP.NET Core Controller Constructor
6 comments
May 15, 2019 - Maui, Hawaii
Ran into a difficulty trying to get access to RouteData() generically outside of Controller code in ASP.NET Core. Specifically I needed to get at route data to pull out a tenant ID required to set up a DbContext with the right connection string to connect to. Getting the route data as part of the DI process in the Controller constructor proved to be challenging. In this post I describe the problem and the work around.
.NET Core SDK Projects: Controlling Output Folders and Dependencies Output
16 comments
April 30, 2019 - Maui, Hawaii
I've been upgrading Markdown Monster to run on .NET Core 3.0 and one of the biggest changes is switching to the new .NET SDK style format for all projects. I ran into some issues with the Addin projects that require that output is placed in a very specific output folder and to not include output of all references. In this post describe a couple of ways to control where output goes and how to limit the output that goes to those folders.
First Steps in porting Markdown Monster WPF App to .NET Core 3.0
9 comments
April 24, 2019 - Maui, Hawaii
I spent a good part of the day today getting Markdown Monster to run on .NET Core 3.0 and in this post I packaged up my notes into a lengthy post with how went through this process. It wasn't exactly quick to make this happen but MM has a few peculiarities that made this process a little bit more trying than it could have been. I'll summarize some thoughts at the end on both the process and the relevance of this process.
Adventures in .NET Core SDK Installation: Missing SDKs and 32 bit vs 64 bit
7 comments
April 20, 2019 - Maui, Hawaii
Ran into a problem yesterday with a new installation of the .NET Core 3.0 Preview 4 installation. Installed the new preview and found that all of my .NET Core 2.x SDKs were no longer showing. A lot of back and forth later I found that I accidentally installed the wrong bitness SDK - 32 bit vs 64 bit. Here's a quick overview of how and why and why you probably NEVER want to install the 32 bit SDK.
Using the ng-BootStrap TypeAhead Control with Dynamic Data
11 comments
April 08, 2019 - Maui, Hawaii
I recently swapped my Auto complete logic in an application to use ng-bootstrap's nice and relatively easy to use TypeAhead control and I ran into a small snag trying to figure out how to bind dynamic data retrieved from the server. The examples show local data binding but fail to show how to load and update the control with remote data. In this post I show how the control works both in sync and async mode and point out the simple solution that eluded my via the Observable switchMap operator.
Creating a custom HttpInterceptor to handle 'withCredentials' in Angular 6+
3 comments
April 07, 2019 - Maui, Hawaii
Client HTTP requests often need to set a few common settings and you don't want to set them on every request. To make this process easier Angular provides an HttpInterceptor class that you can subclass and add custom behavior to for each HTTP request that is sent through the HttpClient. Here's a quick review on how to do this.
ASP.NET Core In Process Hosting on IIS with ASP.NET Core
66 comments
March 16, 2019 - Maui, Hawaii
In version 2.2 ASP.NET Core adds support for direct in-process hosting which improves throughput considerably using an easy mechanism that allows switching between in-process and out-of-process hosting. In this post I describe how to use in process hosting and how it works.
Using .NET Standard with Full Framework .NET
13 comments
February 19, 2019 - Maui, Hawaii
Using .NET Standard on full .NET Framework is a mixed bag because the behavior of .NET Standard differs depending on which version of the Runtime you are integrating with. In this post I review what .NET Standard is and how it fits in with the full .NET Framework and how you can use .NET Standard packages/assemblies in full framework along with some of the problems you have to watch out for.
WPF Hanging in Infinite Rendering Loop
5 comments
February 14, 2019 - Maui, Hawaii
Ran into a nasty WPF bug this week with Markdown Monster that caused MM to hang during startup in certain scenarios. Several users reported issues that I could not duplicate until I started playing around with my screen resolution and scaling. An obscure but insidious WPF bug can cause an application to go into an infinite loop which effectively locks up the application's UI and the app overall. Here's more info on what the problem is and how to work around it.
Ad Blockers, Brave Browser and BrainTree Credit Card Processing SDKs
2 comments
February 08, 2019 - Maui, Hawaii
Ran into an issue with my CC processing forms using Brave today. Brave is a Chromium based browser, but it includes built-in, on-by-default content blocking which apparently causes my order forms to not work as scripts and related page cookies aren't being loaded. Here's what happened and some thoughts on how to work around this.
Finding the ProgramFiles64 Folder in a 32 Bit App
1 comment
February 05, 2019 - Maui, Hawaii
.NET has the `System.GetFolderPath()` method to let you easily retrieve various system folder in a safe way. Unfortunately getting the `Program Files` folder is a bit of problem due to some complications on how the name is retrieved on 32 bit systems. If you're running an application in 32 bit mode, or have an application that can run either 32 or 64 bit, make sure you use the right way to determine where Program Files is located.
COM Object Access and dynamic in .NET Core 2.x
3 comments
January 22, 2019 - Maui, Hawaii
I was surprised to find out that COM Interop works in .NET Core when running on Windows. It's possible to access COM components via Reflection easily enough in .NET Core 2.x. Unfortunately use of the `dynamic` keyword does not work in .NET Core 2.x so for the moment COM interop is limited to using Reflection.
Back to Basics: Non-Navigating Links for JavaScript Handling
10 comments
January 21, 2019 - Maui, Hawaii
When you're creating HTML Anchor links that are non-navigating and handled via script code or through some JavaScript framework, what's the best way to handle the `HREF` navigation link in the HTML? In this back to basics post I look at a few different approaches and what works best.
A Visual Studio to Visual Studio Code Snippet Converter
1 comment
January 14, 2019 - Maui, Hawaii
Visual Studio Code Snippets are very useful and a great productivity enhancing tool for templating reusable code blocks into the editor. I have tons of snippets I use all the time for great productivity savings. Over the last couple of years I've been increasingly using Visual Studio Code and JetBrains Rider and I found myself missing my nearly 150 code snippets from Visual Studio, so I created a small hacky utility to move code snippets from Visual Studio to VS Code and with more limited features to Rider.
Don't let ASP.NET Core Console Logging Slow your App down
16 comments
December 31, 2018 - Maui, Hawaii
Today I ran into a self-inflicted problem with Console logging while playing with a toy test project. By accident I ran the application under load and Console Logging was on and performance was horrendous. In fact nearly 40x slower horrendous. Although my error, there are a few ways this can happen and it's important to understand that Console logging is very, very slow and in this post I show how this happened and why you want to be careful with Console logging in production.
Updating Westwind.AspnetCore.Markdown with Markdown from Files and URLs
December 20, 2018 - Maui, Hawaii
In the last week I've had a need to add some additional features to my Westwind.AspnetCore.Markdown library that provide easier access to Markdown from files and urls as well as the ability to replace the default Markdown parser in the library. In this post I'll discuss some of the feature additions including some implementation notes.
Returning an XML Encoded String in .NET
November 30, 2018 - Maui, Hawaii
XML is not as popular as it once was, but there's still a lot of XML based configuration and data floating around today. Today I ran into a recurring issue where I needed to convert a string to a properly encoded XML string. Seems simple enough but it's not as straightforward as you might think to generate an XML Encoded string properly. This post shows a few different ways to retrieve a string and discusses advantages of each.