Rick Strahl's Web Log

Wind, waves, code and everything in between...
ASP.NET • C# • HTML5 • JavaScript • AngularJs
Contact   •   Articles   •   Products   •   Support   •   Search
Ad-free experience sponsored by:
ASPOSE - the market leader of .NET and Java APIs for file formats – natively work with DOCX, XLSX, PPT, PDF, images and more

Getting around Chrome POST XSS Protection



Ran into an unusual issue where Chrome is blocking user input from a TextArea that includes HTML form and input control input - on the client side. While I'm familiar with server side input validation, this is client side validation that causes the response to be rejected. Here's more info on the error and how to get around it when necessary.

Read more...

Markdown and Cross Site Scripting



I've been getting a number of requests for providing XSS support in my various Markdown components. While Markdown itself makes no provision for HTML Sanitation, if you use Markdown for capturing user input some sort of sanitation is required to avoid potential XSS attacks. In this post I look at XSS scenarios and show how the `Westwind.AspnetCore.Markdown` package deals with removing script tags from rendered Markdown content.

Read more...

Fixing Visual Studio Intellisense Errors



I ran into a problem in one of my applications where Visual Studio was showing errors that were clearly not actual errors. A new feature in Visual Studio now shows separate error listings for Build and IntelliSense errors and it turns out the errors are Intellisense errors. Here's how to fix them and get Visual Studio back onto the straight and narrow.

Read more...

Web Assembly and Blazor: Re-assembling the Web



Web Assembly is changing the way we think about Web development with new ideas and approaches that may not involve JavaScript. Microsoft has put its foot forward with a new Web Assembly based framework called Blazor that combines Razor templates with C# code to provide a rich .NET based front end experience. There's much to think about and understand in this still experimental framework, but the concepts it presents provide a welcome change to the JavaScript status quo. In this post I examine how Web Assembly and Blazor interact, how .NET code is used and give some thoughts on how this technology fits into the Web stack.

Read more...

Creating a WPF ItemSource Length Filter Converter



In this short post I show you you can create a simple Value Converter to limit the max number of items in an ItemsSource value binding in WPF.

Read more...

Explicitly Ignoring Exceptions in C#



In most applications I have a few places where I explicitly need to ignore errors. While generally this isn't a good idea, under some circumstances you just don't care if an error occurs or you simply want a yay or nay response. In this stupid pet tricks post, I describe a few scenarios where not catching any exceptions makes sense along with a couple of helper methods that make these scenarios more explicit so code analyzer and book thrower reviewers can be quieted down.

Read more...

Which .NET Core Runtime Download do you need?



.NET Core has a number of different runtime downloads that you can grab to install. The combinations of downloads can be a bit confusing and it depends on whether you install a development or runtime environment. In this post I describe what each download contains and what you should use it for.

Read more...

Web Code is a solved Problem: How about fixing Web UI next?



These days most of the focus in Web development is on code - JavaScript code in particular. By comparison, the Web UI - HTML and CSS and the browser DOM and support features - feels like it has been stuck in the mud and stagnating for a long time. We now have all the advanced coding tools to do cool stuff, but it seems that HTML and the Web Browser's feature set are really what is holding us back. In this post I look at what's ailing Web UI and try to ruffle some feathers into discussion of how we can affect more rapid change in Web UI features.

Read more...

Updating my AlbumViewer to ASP.NET Core 2.1 and Angular 6.0



Took some time to upgrade my AlbumViewer application to ASP.NET Core 2.1 RC and Angular 6.0. The .NET Core update was very smooth with only very minor adjustments required showing that Microsoft has smoothed out the update path significantly from the frenetic pace of past versions. The Angular update was a bit more involved primarily due to the changes in rxJS.

Read more...

Creating a generic Markdown Page Handler using ASP.NET Core Middleware



I've been talking about Markdown a lot in recent blog posts and this time I'll cover a generic Markdown page handler that you just drop into any site to handle semi-static page editing more easily with Markdown from within an ASP.NET Core application. While Markdown is common fare in CMS or blog applications, it's not so apparent how to get similar generic Markdown document rendering within the context of an existing application. The middleware I describe here allows you to simply drop a markdown file into a configured folder and have it rendered into a stock template. Simple but very useful.

Read more...

Getting the .NET Core Runtime Version in a Running Application



Microsoft has a long history of not providing a reasonable way of looking up the version of the runtime that is hosting your applications. .NET Core is no different and in this short post I show one way you can capture a descriptive name of the runtime executing that's suitable for displaying in your application's info page.

Read more...

Creating an ASP.NET Core Markdown TagHelper and Parser



A couple of months ago I wrote about creating a WebForms based Markdown control. This time around I'll build an ASP.NET Core MVC TagHelper that performs similar functionality for embedding Markdown text into a content area of a Razor page. The component also includes easy access to a Markdown parser using the blazing fast MarkDig Markdown parser.

Read more...

Accessing Configuration in .NET Core Test Projects



.NET Core provides a clean configuration system and in ASP.NET Core that code is automatically configured for you. In test and other non-Web projects however you have to manually configure the configuration provider yourself. In this post I look at a couple of ways to set up a configuration provider both using raw configuration objects or by explicitly configuring through the depedency injection system.

Read more...

Distributing Content and Showing a ReadMe file in a .NET Core Nuget Package



.NET SDK style projects no longer support packaging NuGet content into projects as older projects did. So if you need to ship some dependent content with your library you need to find a different way to do so. In this post I look at a specific example of library that requires additional content and look at how to distribute the extra content as well as displaying a readme file to link to instructions when the NuGet package installs

Read more...

Code Magazine Article: Securing IIS Web Sites with Let’s Encrypt Certificates



Lets Encrypt makes it very easy to create free TLS certificates for your Web site. In this CODE magazine article Rick reviews some of the history of Lets Encrypt and then shows how you can easily take advantage of it to create free and automatically installed and updated certificates for your Windows based IIS Web servers.

Read more...

Easy Configuration Binding in ASP.NET Core - revisited



In this post I'm taking another look at using strongly typed configuration settings in ASP.NET Core, using a slightly simpler approach that foregoes using IOptions in favor of directly using a configuration object instance. In the process I review the various approaches as a summary for getting configuration settings into .NET types.

Read more...

Working around the lack of dynamic DbProviderFactory loading in .NET Core



.NET Core and .NET Standard are missing the DbProviderFactories class which is used to dynamically load ADO.NET DbProviderFactory instances which in turn are used to gain access to the various ADO.NET intrinsic objects generically without requiring an explicit reference to the data access provider. In this post I describe why this can be a problem for libraries that use multiple data providers and show a workaround for loading a DbProviderFactory without taking an explict dependency on the provider assembly.

Read more...

Using Gists for General Purpose Web Pages with Markdown



Most of you probably know and use Github Gists for sharing Code snippets. But did you know that Gists also support Markdown? Using Markdown makes it easy to create much richer code shareable code and even allows for an easy way to create self-contained Web content.

Read more...

Flexing your HTML Layout Muscles with Flexbox



Flexbox is a CSS based technology that makes it much easier to create structured layouts with HTML and CSS. Based on a containership hierarchy, Flexbox combines the structured features of tables with the free form layout capabilities of arbitrary HTML elements that make it possible to create complex , yet flexible HTML designs much more easily that was otherwise possible. My article in CoDe Magazine describes the reasons for Flexbox, the basics of operation and few practical examples you can use today to put flexbox to use.

Read more...

Dev Intersection 2017 Session Slides and Samples Posted



I've posted my Session Slides and code samples from last week's DevIntersection conference on GitHub.

Read more...

.NET Core 2.0 and ASP.NET Core 2.0 are Here



After a long wait .NET Core and ASP.NET Core 2.0 are finally here. This release is a major update from Version 1.0 that brings back a ton of functionality that was originally missing in .NET Core 1.x. With closer compatibility to full framework .NET it's much easier to port existing code to .NET Core, as having a much larger API surface to use in your applications. There are many usability improvements that make it easier to get started using considerable less fanfare. In this post I describe some of what's new and what's great and also a few things that are not so great.

Read more...

Opening a Web Browser with an HTTP Url from Visual Studio Code



Here's a quick tip on how you can create a project specific Visual Studio Task that can launch a Web Browser to a specific page quickly and easily.

Read more...

A few notes on creating Class Libraries for ASP.NET Core



I recently started to collect some of my ASP.NET Core utilities into a helper support library as I tend to do. In the process I ran into a few snags and I realized I was making a few non-obvious mistakes right from the start. In this post I discuss a few of the issues with dependencies and how to deal with them.

Read more...

WPF Slow Window Loading due to Invalid SpellChecking Dictionaries



I ran into a nasty problem with spell checking on WPF, which caused any form that uses spell checking to load extremely slow. It turns out the problem was caused by errant entries in the global Windows dictionary key in the registry. This post describes the problem and how to find and fix your global Windows dictionary settings.

Read more...

Conditional TargetFrameworks for Multi-Targeted .NET SDK Projects on Cross-Platform Builds



If you build multi-targeted .NET SDK projects on multiple platforms you're going to find out that certain targets can't be build on certain platforms. If you target NetStandard and Net45 on a Mac, Net45 is going to fail. In order to get around this you need to conditionally build per platform. Here's how.

Read more...