Teemablogi sissekanded

10.05.2019

Assembly version tag helper for ASP.NET Core

I’m writing some web applications where I must show assembly version in footer of all pages. Applications are published online through Azure DevOps release pipelines and I’m using automatic date based versioning for assemblies. Here is how to show application version using assembly version tag helper. I have multiple pages where version is displayed. Besides layout page there are also standalone pages like login page and error pages. 12:17 10.05.2019 kanalilt DT blogi 2

09.05.2019

Using query tags with Entity Framework Core 2.2

Entity Framework 2. 2 introduces query tags that make it easier to find specific queries from logs and output windows of Visual Studio. When running application on development box it’s possible to live without query tags. We can set breakpoints to see SQL generated from LINQ queries. 08:47 09.05.2019 kanalilt DT blogi 2

07.05.2019

Hosting WordPress on Azure

Another day, another disaster with shared hosting. And not this usual gateway-is-down-problem when people are visiting my blog. I started my journey with simple idea – why not WordPress on Azure? After some experiments I got my first results and the picture wasn’t as terrible pricewise as I thought. Here’s my first experiment with WordPress on Azure. 06:19 07.05.2019 kanalilt DT blogi 2

06.05.2019

Lightweight custom authentication with ASP. NET Core.

ASP. NET Core Identity is popular choice when web application needs authentication. It supports local accounts with username and password but also social ID-s like Facebook, Twitter, Microsoft Account etc. But what if ASP. NET Core Identity is too much for us and we need something smaller? What if requirements make it impossible to use it? Here’s my lightweight solution for custom authentication in ASP. NET Core. 09:09 06.05.2019 kanalilt DT blogi 2

23.04.2019

Serializing objects to URL encoded form data

While messing with dictionaries to create form data for FormUrlEncodedContent so I can send data to server using HTTP client, I started thinking about easier and cleaner way to do it. I was writing integration tests and I wanted to re-use some model classes instead of dictionaries. Here’s how to do it. Sample of integration test is incluced. Those who are currently writing integration tests for some ASP. 07:53 23.04.2019 kanalilt DT blogi 2

22.04.2019

Writing to CSV-file from multiple threads

I was writing document and metadata exporter that reads data from SharePoint and writes it to multiple files. I needed to boost up performance of my exporter and I went with multiple threads pumping out the data from SharePoint. One problem I faced – writing metadata to CSV-files from multiple threads in parallel. This blog post shows how to do it using concurrent queue. This posting uses CsvHelper library to write objects to CSV-files. 08:00 22.04.2019 kanalilt DT blogi 2

12.04.2019

File uploads in ASP.NET Core integration tests

Writing integration tests for ASP. NET Core controller actions used for file uploads is not a rare need. It is fully supported by ASP. NET Core integration tests system. This post shows how to write integration tests for single and multiple file uploads. Getting started Suppose we have controller action for file upload that supports multiple files. It uses complex composite command for image file analysis and saving. 08:00 12.04.2019 kanalilt DT blogi 2

11.04.2019

What’s new in next version of Microsoft Edge

Next version of Microsoft Edge browser is replacing its current rendering engine and in future it will run on Chromium – the same rendering engine used by Google Chrome browser. Edge gets total rework and ends one era in Microsoft history on browsers field. With new browser there will come interesting new features. Here is overview of insiders release of next Microsoft Edge. 13:36 11.04.2019 kanalilt DT blogi 2

09.04.2019

Using ASP. NET Core Identity user accounts in integration tests.

I have application that uses ASP. NET Core Identity with classic logins and there’s need to cover this application with integration tests. Some tests are for anonymous users and others for authenticated users. This blog post shows how to set selectively set authenticated ASP. NET Core Identity user for ASP. NET Core integration tests. Getting started We start with ASP. 06:40 09.04.2019 kanalilt DT blogi 2

05.04.2019

Using custom startup class with ASP. NET Core integration tests.

My previous post demonstrated how to use custom appsettings. js file with integration tests in ASP. NET Core. But in practice it’s not enough and very often we need custom startup class that extends the one in web application project to configure application for integration tests. This blog post shows how to do it. Getting started Using custom startup class is a little bit tricky. 07:35 05.04.2019 kanalilt DT blogi 2

04.04.2019

Using custom appsettings. json with ASP. NET Core integration tests.

ASP. NET Core introduced the concept of TestServer for integration testing of web applications. Integration tests need web application run with all bells and whistles to make sure that all components work together with no flaws. Often we need special settings for integration tests as web application cannot use live services and easiest way to do it is to use special appsettings. json file. This blog post shows how to do it. 08:34 04.04.2019 kanalilt DT blogi 2

02.04.2019

Conditionally include partial view in ASP.NET Core

I have ASP. NET Core web application where I need to include partial view only if it exists. The application uses areas and some areas may have their specific side menu. This blog post shows two ways how to conditionally include partial view to ASP. NET Core layout page. My goal was to do it the easiest way possible by using out-of-box things and making sure I don’t create ugly looking mess. 09:33 02.04.2019 kanalilt DT blogi 2

30.03.2019

Implementing INotifyPropertyChanged

Short post about how to implement INotifyPropertyChanged without using any advanced tooling. I have some small UWP applications where I’m using MVVM to separate presentation and logic. Here is how I use INotifyPropertyChanged with base class for multiple view models. First introduction to INotifyPropertyChanged comes usually through some existing view model. 11:46 30.03.2019 kanalilt DT blogi 2

18.03.2019

Speaking at Microsoft Ignite – The Tour 2019, Amsterdam

This week I will speak at Microsoft Ignite – The Tour conference happening at Amsterdam. I have presentations on both days and I’m pushing here to get all things done before my departure. Here’s the short overview of my presentations. BRK3760 – Working with Vision API Of Microsoft Cognitive Services Short introduction and practical set of demos introducing computer vision API of Microsoft Cognitive services. 14:15 18.03.2019 kanalilt DT blogi 2

09.03.2019

Connecting Samsung Smart TV to speakers

Few months ago I bought new Samsung smart TV with 43” UHD screen. It’s for small room. Big was my surprise if I found out that it’s not so easy to connect this very smart device to regular speakers as there’s no analog audio output. After visit to local electronics and audio shop my problem got solved. Here’s how to make Samsung Smart TV works with external speakers. Speakers I have Logitech Z623 speaker system. 11:00 09.03.2019 kanalilt DT blogi 2

08.03.2019

Worker Service template in .NET Core 3.0

With ASP. NET Core 3. 0 Preview 3 we have template for background processes like Windows services and Linux daemons. New project template is called Worker Service and this writing shows how it works and how to use it. Creating worker service application After downloading . NET Core 3. 0 Preview 3 open Visual Studio 2019, create new ASP. NET Core web application and select Worker service as project type. 08:37 08.03.2019 kanalilt DT blogi 2

07.03.2019

.NET Core 3.0 Preview 3 now available!

NET Core 3. 0 Preview 3 is out and there are many interesting updates to framework and to ASP. NET Core. Here’s the list of most important updates. Downloads are available here. Updates to . NET Core 3. 0: More support for Indexes and Ranges in C# . NET Standard 2. 1 support. To target . NET Standard edit project file and specify netstandard2. 1 as target framework. . NET Standard 2. 1 is not supported by full. 09:55 07.03.2019 kanalilt DT blogi 2

06.03.2019

Pre-compressed static files with ASP.NET Core

Optimizing web applications is important because more economic web applications consume less CPU cycles and need less bandwidth – resources we have to pay for. It’s easy to turn on response compression on ASP. NET Core, but serving pre-compressed files needs more work. This blog post shows how to do it. 09:46 06.03.2019 kanalilt DT blogi 2

05.03.2019

Fail build on Azure DevOps for low code coverage

As my ASP. NET Core code coverage reports work nice in Azure DevOps build pipeline I took step forward and made builds fail on Azure DevOps if percent of lines covered is below 60. This blog post shows how to do it using ReportGenerator and Build Quality Checks build tasks. Preparing build pipeline This post expects that there’s build pipeline already defined on Azure DevOps and it produces code coverage reports. 09:00 05.03.2019 kanalilt DT blogi 2

04.03.2019

Entity Framework Core supports constructors with arguments

Keeping objects complete and valid all the time is strategy used in different methodics. It’s perhaps most popular in Domain Driven Design (DDD). Entity Framework Core 2. 1 made big step forward on supporting entities that doesn’t have default empty constructor. This blog post shows how to use Entity Framework Core and entity constructors with arguments. 09:09 04.03.2019 kanalilt DT blogi 2