Subscribe: Rick Strahl's Web Log
http://www.west-wind.com/weblog/rss.aspx
Added By: Feedage Forager Feedage Grade B rated
Language: English
Tags:
application  browser  code  control  core  iis  net core  net  package  project  visual studio  web browser  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



 



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

Fri, 13 Oct 2017 21:28:20 GMT

Here's a quick tip for Visual Studio Code and how to open the current document in a Web Browser. I've been using Visual Studio Code more and more in recent months and it just keeps getting better and better as a general code editor. I like the speed and it the environment 'just feels' very comfortable to work in. While I still use other editors for full on development most of the time for their IDE features, for quick edits or updates I tend to always use Visual Studio Code. I especially like it for Web development of all sorts, although for heavy duty work I still prefer WebStorm for its true IDE features (heavy duty refactoring, auto-complete, CSS and HTML navigation features). For heads down coding VS Code is very nice and just feels better than most other editors. But one thing I miss is a quick and easy way to launch a browser from the current HTML document I'm editing either locally running from disk, or on my currently running development Web server. But luckily it's quite easy to create a new custom Task in Visual Studio and add it to your project. If you use Visual Studio Code for Web editing and you quickly want to preview and HTML page in a browser, here's a simple way you can add a task to open a Web Browser. Creating a new Task in tasks.json To do this: Bring up the Command Pallete (Ctrl-Shift-P) Type in Task or Configure Task This brings up the Task editor for the current project, which edits a tasks.json file in the .vscode folder in the editor root where you opened the editor. You can now add tasks. I'm going to add two tasks to open Chrome with the current open document as a fixed HTML URL with the project relative path: { "version": "0.1.0", "tasks": [ { "taskName": "Open in Chrome", "isBuildCommand": true, "command": "Chrome", "windows": { "command": "C:/Program Files (x86)/Google/Chrome/Application/chrome.exe" }, "args": [ "http://localhost:5000/${relativeFile}" ] }, { "taskName": "Open in Firefox", "isBuildCommand": true, "command": "Firefox", "windows": { "command": "C:/Program Files (x86)/Mozilla Firefox/firefox.exe" }, "args": [ "http://localhost:5000/${relativeFile}" ] } ] } This hooks up the tasks as build tasks. Pressing Ctrl-Shift-B fires the first build task automatically - in this case Chrome. Alternately: Bring up the Command Console (Ctrl-Shift-P) Type Run Task Pick from the list of tasks Launching HTML from the File System The code above uses a hardcoded project specific URL that hits a local Web server. You can also just preview the file from disk which is a little more generic. { "taskName": "Open as HTML File", "isShellCommand": true, "command": "Shell", "windows": { "command": "explorer.exe" }, "args": [ "${file}" ] } This will use whatever browser is configured on Windows and launch it from the local file system. Easy Extensibility The more I look in Visual Studio code the more i find to like. The extensibility model is super easy so it's easy to add things like code snippets or as I've shown here tasks that are tied to a hotkey. There's a lot more you can do with tasks - so be sure to check out the documentation linked below. Resources Visual Studio Code Tasks Documentation this post created and published with Markdown Monster © Rick Strahl, West Wind Technologies, 2005-2017Posted in Visual Studio Code   [...]



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

Tue, 26 Sep 2017 16:09:13 GMT

I'm starting to collect some of my helper and utility classes into a reusable library (as I tend to do) for my ASP.NET Core projects. In the process I ran into a few snags and after a brief discussion with David Fowler on Twitter I realized I was making a few non-obvious mistakes right from the get go. In this quick post I point at couple of things I ran into and that you might also want to watch out for when creating class libraries that depend on ASP.NET Core features. Don't Reference the ASP.NET Core Meta Package On first glance it seems the easiest way to ensure you get access to all of ASP.NET's Features in your support library, is to reference the Microsoft.AspNetCore.All meta package that brings in all of the ASP.NET Core dependencies, just like a default ASP.NET Core Web application does. The All package is good way to go for top level applications, especially those that target the pre-installed .NET Core runtimes. The ASP.NET Publish process can deal with sorting out where assemblies come from and in most cases referencing the meta package with its references to all packages just points at the preinstalled assemblies. .NET then sorts out at JIT time which assemblies are actually loaded. So when I created my class library I figured, why not use the same package and add it to my classlib project - after all most use cases will already have the meta package in the top level project anyway. Alas - David wagged a digital finger at me and reminded me that that this is not a good idea: In hindsight, this makes perfect sense. If you stick the class library's package into another project it inherits the dependencies - ie. the entire ASP.NET stack. In most cases this probably not an issue, because the ALL meta package is probably already referenced in the top level Web project. Nothing gained, nothing lost, right? But, in some cases the package might go into a purely local installation of an application that is using just the dependencies it needs rather than opting into the full ASP.NET Stack pointing at a pre-installed runtime. Now the consumer all of a sudden has to take a dependency on all those assemblies for whatever specialized functionality my lib provides. Worse, if some other class library want to reference your package, it now too has a dependency on the full ASP.NET stack. Not cool. In short, if you're building an internal library that you know will always be consumed in an application that uses the full meta package, then it's probably OK to reference the meta package in your class library. But for any library that is going to be used generically in any kind of ASP.NET Core project or possibly as a dependency to other libraries, it's much more prudent to reference just the minimal dependencies you actually need. ASP.NET Core Class Libraries and .NET Standard A related issue came up when creating the ASP.NET Core class library project. I typically create class libraries that target .NET Standard 2.0 because it potentially makes the library more portable. With ASP.NET Core that's probably not a critical requirement right now as it always targets .NET Core App (not .NET Standard), but who knows what the future holds. But when I referenced the ASP.NET Core meta package the class library project automatically forced me to target .NET Core 2.0. Figure 1 - Using the Microsoft.AspNetCore.All package forces you to use the NETCoreApp2.0 target Not only that but the drop down list actually doesn't give the option to change the target in Visual Studio - it only gives me options for .NET Core. What's going on? Well, the ASP.NET Core meta package is actually responsible for changing the target, but I can change it manually in the .csproj file: netstandard2.0 However when I did that[...]



WPF Slow Window Loading due to Invalid SpellChecking Dictionaries

Mon, 25 Sep 2017 17:54:30 GMT

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.(image)



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

Mon, 18 Sep 2017 18:07:57 GMT

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.(image)



Accepting Raw Request Body Content in ASP.NET Core API Controllers

Thu, 14 Sep 2017 18:39:53 GMT

When posting raw body content to ASP.NET Core the process is not very self-explanatory. There's no easy way to simply retrieve raw data to a parameter in an API method, so a few extra steps are provided using either manual handling of the raw request stream, or by creating custom formatter that can handle common 'raw' content types in your APIs via standard Controller method parameters. In this post I look at various permutations and how you can access the raw data in your code.(image)



A Literal Markdown Control for ASP.NET WebForms

Wed, 13 Sep 2017 17:00:50 GMT

Spent some time last night creating a small ASP.NET Server control that can render literal Markdown text inside of ASPX pages and turn the literal text into Markdown. It's a very simple control, but it makes it lot easier to edit documents that contain simple formatted text content without having to deal with angle brackets for lengthier text.(image)



Configuring LetsEncrypt for ASP.NET Core and IIS

Sat, 09 Sep 2017 17:12:01 GMT

LetsEncrypt makes it easy to create SSL certificates for your applications for free and lets you automate the process. When using LetsEncrypt with IIS and ASP.NET Core however a few extra steps are required to make an ASP.NET Core site work with LetsEncrypt. I show you how in this post.(image)



Handling HTML5 Client Route Fallbacks in ASP.NET Core

Mon, 07 Aug 2017 17:40:07 GMT

HTML5 client routes work great on the client, but when deep linking into a site or pressing refresh in the browser, HTML5 client side routes have a nasty habit of turning into server HTTP requests. Requests to routes that the server is likely not configured for. In this post I look at why HTML5 client routes require server cooperation to handle and how to set them up on IIS and/or ASP.NET Core.(image)



Updating Windows Applications and Installers for non-Admin Installation

Tue, 18 Jul 2017 06:54:04 GMT

I recently updated Markdown Monster to run as a non-admin installation even when running the full installer. There have been many requests for this functionality and in this post I describe several of the updates required in order to make this work.(image)



JavaScript Debugging in a Web Browser Control with Visual Studio

Fri, 07 Jul 2017 02:24:15 GMT

Debugging a Web Browser Control embedded in a Windows application can be a bear because there's no obvious way to debug the the JavaScript code or HTML DOM/CSS inside of the application. Although the Web Browser uses the Internet Explorer Engine for HTML rendering and JavaScript execution and provides most of the engine features, the Debugger and F12 are not part of that. As it turns out you can use Visual Studio to hook up a script debugger and provide a rich debugging experience with the full IE debugger, Console and even a DOM/CSS Explorer. In this post I show how.(image)



Debouncing and Throttling Dispatcher Events

Mon, 03 Jul 2017 05:32:49 GMT

In UI applications it's not uncommon for a number of UI events to fire more events than your application can handle. In order to limit the number of events it's often a good idea to throttle or 'debounce' events so that only a single event is fire for a given period. In this post I describe a Dispatcher based implementation for debouncing and throttling UI events in WPF applications.(image)



Multi-Targeting and Porting a .NET Library to .NET Core 2.0

Thu, 22 Jun 2017 16:46:07 GMT

I've been holding off porting any of my full frameworks to .NET Core. With the latest .NET Core 2.0 and .NET Standard 2.0 releases and their vastly larger footprints that match more closely with what we expect of the .NET Framework feature set, migrating looks a lot more appealing. In this post I describe the process of porting one of my general purpose full framework libraries to .NET Standard 2.0 and in the process also creating a multi-targeted project that compiles .NET 4.5, 4.0 and .NET Standard projects.(image)



Bypassing IIS Error Messages in ASP.NET

Thu, 01 Jun 2017 22:30:42 GMT

IIS Error handling is the source of lots of confusion. I've been using IIS for nearly 20 years now, and figuring out the right combination of error configuration settings and code to properly serve custom error pages or error responses in API still makes fumble a few times before I get it just right. This post provides a few hints and some background on how to deal with error handling.(image)



Automating IIS Feature Installation with Powershell

Thu, 25 May 2017 19:30:28 GMT

IIS often gets a bad wrap for being diffcult to install and configure. However, using some of the built-in tooling for administration using PowerShell it's actually quite easy to configure IIS and even set up a new site and application pool with a few short scripts that are much quicker, and more repeatable than using the various Windows UI features. Here's how.(image)



Upgrading to .NET Core 2.0 Preview

Tue, 16 May 2017 04:42:00 GMT

With the release of the first preview of .NET Core 2 and ASP.NET Core 2.0 I decided to upgrade my AlbumViewer sample application to the latest bits and preview tools. Overall the experience was pretty smooth, but I ran into a couple of breaking changes and a few tooling snags that I'll describe in this post.(image)



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 properly configure ASP.NET Core applications using the AspNetCoreModule and IIS Rewrite Rules(image)



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)