Subscribe: Rick Strahl's Web Log
http://feeds.feedburner.com/RickStrahl
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
application  core  iis  kestrel  markdown monster  net core  net  project  server  visual studio  web server  web  windows 
Rate this Feed
Rate this feedRate this feedRate this feedRate this feedRate this feed
Rate this feed 1 starRate this feed 2 starRate this feed 3 starRate this feed 4 starRate this feed 5 star

Comments (0)

Feed Details and Statistics Feed Statistics
Preview: Rick Strahl's Web Log

Rick Strahl's Web Log



Life, Surf, Code and everything in between



 



Upgrading to .NET Core 2.0 Preview

Tue, 16 May 2017 04:42:00 GMT

Over the weekend I spent a bit of time updating my AlbumViewer Sample Angular and ASP.NET Core Application to .NET Core 2.0. The good news is that for the most part this is another relatively smooth update, with some nice payoffs, but also a couple of pain points. Album Viewer Just to set the stage for those of you that haven't heard me blabber about my sample project before: I have an AlbumViewer sample application I've been carrying forward through all the versions of .NET Core (and Angular as well) from earlier previews to today. The album viewer is a smallish application of a .NET Core ASP.NET API to an Angular (4) front end application that's made up of four separate projects: ASP.NET Core Web app that handles the Web API backend .NET business object project that holds Repository and EF access code .NET utility project with a few helpers Angular front end Web Site Project (discussed in detail in my previous update post) Although the project is relatively small that could easily live in a single project, I broke out functionality into multiple projects to make it a little more realistic and exercise the the inter-project dependencies and different behaviors of Web and separate class library projects under .NET Core. You can find the project on Github at: AlbumViewer Sample Project on GitHub and the running application (currently on 1.1 still): AlbumViewer Online Sample Updating my AlbumViewer Sample to .NET Core 1.1 and Angular 4 The conversion for .NET Core 2 discussed in this post currently lives on a side GitHub branch NET_CORE_2_MIGRATION for the time being until there's more stable tooling available. As with the 1.1 upgrade, the .NET Core 2 features require the latest version of Visual Studio Preview in order to work. So the Master branch will continue to stay on version 1.1 of .NET Core that can run comfortably on current production tools and runtimes. Getting started with .NET Core 2.0 In order to use the .NET Core 2.0 features you'll need to install a couple of things: .NET Core 2.0 SDK Visual Studio 2017 v15.3 Preview 1 Visual Studio is optional if you want to work from the command line or you're not running on Windows. The SDK is the key piece you need. Important! Even if you install the Visual Studio Preview, you'll still need to install the .NET Core 2 SDK as the Preview 1 release of Visual Studio does not install it. This will change in the future, but for now - install it explicitly. Upgrading to .NET Core 2.0 and .NET Standard 2.0 - mostly easy So, the good news is that 99% of the upgrade to .NET Core was very easy and quick and boiled down to a few very simple steps: Changing the target of the Class Library projects to .NET Standard 2.0 Changing the target of the Web API project to .NET Core App 2.0 In the Web Project adding a reference to Microsoft.AspNetCore.All In the Web Project removing most other ASP.NET related Nuget references And that's it! Let's go over those. Changing the Target Framework I used Visual Studio to change the Build target of each of the 3 projects. The Class Libraries are set to target .NET Standard 2.0, while the Web app targets .NET Core 2.0. Here's the setting to .NET Standard 2.0 in the class library projects: Figure 1 - Setting .NET Standard 2.0 in Visual Studio's Build Settings for the class library projects Making this change causes the TargetFramework to be changed to netstandard2.0 in the project's .csproj file. If you're not using Visual Studio you can also make this change directly in the .csproj file: netstandard2.0 ... ... In the Web App the settings look slightly different - there you have to use netcoreapp2.0 for the TargetFramework. Figure 2 - Configuring .NET Core version in a Web Project and here are the settings for the .csproj file:



IIS and ASP.NET Core Rewrite Rules for Static Files and Html 5 Routing

Fri, 28 Apr 2017 02:26:44 GMT

If you're running ASP.NET Core under Windows with IIS, you'll want to take advantage of letting IIS serve up your static content and handle your HTML 5 Client and home routes. IIS is very efficient at handling static content and content re-routing and in this post I describe how you can configure ASP.NET Core applications using the AspNetCoreModule and IIS Rewrite Rules. When running ASP.NET Core under IIS, a special module handles the interaction between IIS and the ASP.NET Kestrel Web Server. There are a number of ways how you can handle the interaction between IIS and Kestrel in regards to what server handles what specific types of requests. I talked about this in my More on Running ASP.NET Core on IIS post a few weeks back. Based on the discussions that followed, the most interesting part of that post revolved on how to set up IIS correctly to allow separation of the API content that the Web API application creates and the static content that the rest of the site requires. In this post I revisit that discussion that revolved around handing off static content to IIS, and in this post I add a few additional considerations regarding client side routing and root URL handling. IIS and Kestrel When running ASP.NET Core applications in production, it's a recommended practice to run a front end Web Server to handle the ‘administrative’ part of a typical Web server. There's more to a Web Server than merely serving up content from a source, and full featured Web Servers provide a number of features that Kestrel does not provide natively and arguably shouldn't. I've shown the following diagram a few times recently, but it's good to show it yet again to visualize how IIS and Kestrel interact when you run ASP.NET Core applications under IIS: Kestrel is ASP.NET Core's internal Web Server and when you run an ASP.NET Core application you usually run Kestrel as part of the .NET Core application. Unlike classic ASP.NET which integrated tightly with IIS, ASP.NET Core handles its own Web server processing through a default Web server implementation that is Kestrel. Kestrel is very high performance Web server that is optimized for raw throughput. It's considerably faster in raw throughput than running ASP.NET, but at the same time it's also a basic Web Server that doesn't have support for the full feature set of a full Web Server platform like IIS, Apache or even something more low level like nginx. Kestrel has no support for host headers so you can't run multiple Kestrel instances on the same port, content caching, automatic static file compression or advanced features like lifetime management of the server process. While it's certainly possible to run Kestrel on a single port directly, most commonly you typically end up running Kestrel behind a front end Web server that acts as a proxy. Incoming requests hit the front end server and it forwards the inbound requests from port 80 or 443 typically to Kestrel on its native port. The front end can handle static file serving, content caching, static file compression, SSL certs and managing multiple sites tied to a single IP on port 80. On Windows this typically means you'll be running Kestrel behind IIS as shown in the figure above. Although I show IIS here, the same principles discussed in this article can also be applied to other Web Servers that act as front ends, such as nginx, Apachy or HA Proxy on Linux. This article discusses the issues in terms of IIS, but the concepts can be applied to other Web Servers on other platforms with different configuration settings. Use the right Tool for the Job When building Web applications, you'll want to break out what server serves appropriately. Typically this means: IIS Handles Static Files Handles HTML 5 Client Side Routing Kestrel Handles all API Requests The AspNetCoreModule When you run in IIS, there's an AspNetCoreModule that handles the interaction between IIS and Kestrel. In order to use the AspNetCoreModule on a Windows server, make sure you install the Windows Server Hosting Bundle from th[...]



Creating a Markdown Monster Addin: Save Images to Azure Blob Storage

Mon, 17 Apr 2017 16:30:29 GMT

The Markdown Monster Markdown Editor and Weblog Publishing tool has a .NET based addin model that makes it relatively easy to extend its core feature set with custom functionality. In this post I show how you can quickly create an addin of your own, and then show a practical example that demonstrates how add Image uploading to Azure Blob storage as an interactive addin.(image)



Running .NET Core Apps under Windows Subsystem for Linux (Bash for Windows)

Thu, 13 Apr 2017 19:53:07 GMT

The Windows Shell for Linux (WSL or Bash on Ubuntu on Windows) provides a nice way for Windows and Linux to interact without the overhead of dealing with a separate VM. Using the WSL you can now also run your .NET Core applications directly under Linux without requiring a VM or Docker. In this post I demonstrate how the shell works and how you can run your .NET and ASP.NET Core applications to test operation under Linux.(image)



Virus Scanning Madness for Software Distribution

Sun, 02 Apr 2017 19:22:35 GMT

I've been having having lots of problems recently with VirusTotal, which is used by Chocolatey to scan for malware in Chocolatey distribution packages. VirusTotal is a Web based service that aggregates around 60 virus scanners against an installation binary. The problems is that I frequently see random malware hits by various obscure scanners. In this post I describe the problem and the farce that this has become as some of the malware hits are obviously false positives that actually reverse in a rescan.(image)



Updating my AlbumViewer Sample to ASP.NET Core 1.1 and Angular 4

Fri, 31 Mar 2017 08:05:54 GMT

I updated my AlbumViewer sample application recently to the latest versions of ASP.NET Core (1.1) and the new .csproj project as well Angular 4(image)



More on ASP.NET Core Running under IIS

Fri, 17 Mar 2017 05:40:45 GMT

Since my last post about hosting ASP.NET Core on IIS I've gotten quite a few questions and comments in regards to working with this mixed IIS/Kestrel hosting environment. There are quite a few not so obvious arrangement in this set up and some surprising discoveries in terms of performance and segragation of feature usage between IIS and Kestrel.(image)



Dragging and Dropping Images and Files into the Web Browser Control

Fri, 10 Mar 2017 09:23:34 GMT

Dragging content into the Web Browser control and capturing the content dropped can be tricky. The Web Browser Control is based on Internet Explorer and is actually an ActiveX control hosted inside of a container and because of that is difficult to deal with. In this post I describe how you can get around this issue and still capture images and files dropped on the control and handle the drop operations.(image)



Debugging the Web Browser Control with FireBug

Wed, 08 Mar 2017 10:09:31 GMT

If you need to debug JavaScript code or layout issues in a Web Browser control inside of a Windows desktop application, you've probably found that the experience sucks. Although Internet Explorer on which the control is based suppports rich developer tools, those are not available in the Web Browser control. Enter an oldie but goodie: FireBug which is an embeddable Console implementation that provides a lot of the features that you find in modern browser developer tools and with a couple of lines of html you can add this debugger into your application.(image)



Getting JavaScript Properties for Object Maps by Index or Name

Sat, 04 Mar 2017 21:59:11 GMT

Getting value out of maps that are treated like collections is always something I have to remind myself how to do properly. In this post I look at JavaScript object iteration and picking out values from a JavaScript object by property name or index.(image)



Video Rendering Issues for WPF Windows

Tue, 14 Feb 2017 00:57:23 GMT

Recently I ran into a few reports of black screen of death rendering of Markdown Monster when starting up from a very few users of the application. They reported the screen just shows black, while actually being responsive to moving and showing menus etc. Also moving to another screen often fixes the problem. It turns out this is a hardware related issue with WPF with certain video hardware/monitor combinations. In this post I describe the problem and the workaround to get the application to render properly even on compromised hardware.(image)



Empty SoapActions in ASMX Web Services

Sun, 12 Feb 2017 19:12:01 GMT

Recently I had to deal with an ASMX Web Service that was receiving empty SoapActions from the client. ASMX doesn't like that, but luckily there's an easy work to strip out the errant Soap header.(image)



Creating a portable and embedded Chocolatey Package

Sun, 29 Jan 2017 21:05:40 GMT

Chocolatey is an awesome tool to install software. As a publisher you have a lot of choices of how to create packages and in this post I describe the two packages that I use with Markdown Monster, which is a full downloaded installer package and a fully self contained embedded portable package. Here I cover the basics of Chocolatey package creation and some of the steps required to create a portable package from a full installation and some of the challenges you might run into along the way.(image)



Adding Files to Visual Studio Projects

Wed, 25 Jan 2017 19:35:31 GMT

Visual Studio has a boat load of ways to add new files to a project and various extensions and tools provide even more ways to do the same. Even so the experience to add new files to a project in Visual Studio is one of the most tedious tasks. Here's what bugs me and how I try to work around the verbosity of it all.(image)



New CODE Magazine Article: Getting down to Business with ASP.NET Core

Thu, 12 Jan 2017 20:19:27 GMT

The latest issue of CODE magazine features my `Getting down to Business with ASP.NET` Core article as the cover article. The article focuses on building an ASP.NET Core backend for an Angular 2 front application, covering all aspects of separating business and Web app logic, dealing with EF Core data access in related tables, CORS to be able to run across domains and simple authentication in a client centric REST service application. Check it out.(image)



Faking out the .NET Runtime Version

Tue, 10 Jan 2017 07:04:01 GMT

I've been struggling with DPI Scaling issues in WPF in Markdown Monster and .NET 4.6.2 has a few fixes that address the problems I've been working on. However, requiring 4.6.2 is a problem due to lowish adoption rates and skittishness about installing new versions of .NET. In this post I show a little hack that allows me to compile my app to .NET 4.6.2 but don't require user to have that version installed so those that have it can take advantage of the updates.(image)



Back to Basics: String Interpolation in C#

Tue, 27 Dec 2016 08:12:59 GMT

String Interpolation provides string templating for string literals in C#. Rather than using string.Format you can use string interpolation to produce much more readable code that embeds expression values directly into string literals rather than escaping numeric arguments as you do with string.Format(). In this post I look at how string interpolation works, what the compiler does under the covers and some common use cases where it makes life easier.(image)



Downgrading a .NET Applications from 64 bit to 32 bit for the WebBrowser Control

Fri, 23 Dec 2016 09:14:52 GMT

Recently while working on Markdown Monster I ran into some odd crashes and behaviors when interacting with the Web Browser control in this WPF application. It turns out that some of these inconsistent behaviors are apparently caused by running hte application in 64 bit mode. Switching to 32 bit mode has made the application and Web Browser interaction much more responsive and has stopped the nagging unexplainable crashes. In this post I look at 32 and 64 bit applications in .NET and outline some of the issues I ran into and how I fixed the problem by switching to building a 32 bit app.(image)



Visual Studio Debugging and 64 Bit .NET Applications

Mon, 19 Dec 2016 08:26:59 GMT

Recently while debugging a 64 bit application I found out the hard way that Visual Studio by default will use 32 bit debugging even when running what would otherwise be a 64 bit .NET application. There are a number of options that determine the bitness of your application, but the debugger often behaves differently than your standalone application. In this post I describe, why this might be a problem in some situations and how you can get the debugger to run in 64 bit.(image)



WPF Rendering DUCE.Channel Crashes due to Image Loading

Thu, 15 Dec 2016 09:43:47 GMT

I ran into a nasty WPF rendering bug that affected only a few select machines. Rendering problems in WPF can be terribly difificult to debug because there often is no additional information on what failed and the exceptions that occur are not trappable but fall back to application wide error handling. In this post I describe a specific failure caused by a 'bad' image WPF can't deal with and how I tracked it down and fixed it.(image)



Loading .NET Assemblies out of Seperate Folders

Mon, 12 Dec 2016 09:49:25 GMT

In the process of updating the Addin manager in Markdown Monster I ran into a few snags with loading .NET assemblies out of separate folders. Assembly loading out of non base folders in .NET can be problematic and sure enough I ran into a few issues that took a while to find a work around for. In this post I describe some of the issues of folder based assembly loading and a brute force solution to deal with assembly resolution.(image)



.NET Standard 2.0 - Making Sense of .NET Again

Wed, 23 Nov 2016 09:29:40 GMT

It's taken awhile but it seems Microsoft is finally nailing the message for .NET going forward and .NET Standard with its common API specification is a huge part in making sure that the same base library of .NET is available on all .NET platforms. In this post I look at what .NET Standard is, how it works and what some of the surrounding issues and impacts are for the .NET Eco system.(image)



Introducing Markdown Monster - a new Markdown Editor

Fri, 04 Nov 2016 08:14:57 GMT

I'm happy to announce Version 1.0 of Markdown Monster a Markdown Editor and Weblog Publishing tool for Windows. In this post I give a quick tour of Markdown Monster and provide links to all you need to know to check out this great new Markdown editor.(image)



Windows Update Hell

Thu, 03 Nov 2016 19:26:45 GMT

I've been fighting Windows Update Hell for the last month with failed updates wreaking havoc on my machine. Updates fail to install completely and roll back and then continue to retry each day. Attempts to turn off the particular update now fails as well, so I'm stuck in this groundhog day like loop of pain. This is a cry for help, in hopes somebody has additional ideas on what to try.(image)



C# NumberFormat Sections

Thu, 03 Nov 2016 17:27:56 GMT

In all the years I've been using C#, I've completely missed that the NumberFormat features using .ToString() or string expressions support sections for positive, negative and zero values. In this post I describe the feature and how it works.(image)