View Components as Tag Helpers in ASP.NET Core

Posted by Anuraj on Wednesday, December 7, 2016

ASP.NET Core MVC View Components Tag Helpers

This post is about using View Components as Tag Helpers in ASP.NET Core. This feature is from ASP.NET Core 1.1 version onwards. In ASP.NET Core View Components are similar to partial views, but they are much more powerful. View components do not use model binding, and only depend on the data you provide when calling into it. View components can be used for Login panel, Dynamic navigation menus, Tag cloud etc.

Using Automapper in ASP.NET Core project

Posted by Anuraj on Friday, December 2, 2016

AutoMapper ASP.NET Core MVC

This post is about using Automapper in ASP.NET Core project. AutoMapper is an object-object mapper which allows you to solve the problem of manually mapping each property of a class with the same properties of another class. Before AutoMapper, if you want to map properties of one object to another, you have manually assign each of the property objects, it will hard and error-prone if an object got lot of properties. If you are a MVC developer most of the time you manually map model objects with viewmodel objects. AutoMapper helps to do it in clean and readable way. For using AutoMapper, first you need to set the mapping classes in AutoMapper, you can use CreateMap method for this. To for map classes, you can use Map method.

Using FluentAssertions in dotnet core unit tests

Posted by Anuraj on Thursday, December 1, 2016

dotnet core FluentAssertions xUnit

This post is about using FluentAssertions in xUnit unit tests. Fluent Assertions is a set of .NET extension methods that allow you to more naturally specify the expected outcome of a TDD or BDD-style test. It has better support for exceptions and some other features that improves readability and makes it easier to write unit tests. In this post I am using ASPNET Yo man generator to create unit tests. And I have added FluentAssertions reference via project.json file.

Control the name of the dotnet core application output

Posted by Anuraj on Tuesday, November 29, 2016

ASP.NET Core .NET Core dotnet

This post is about configuring the output filename of a .NET Core application. By default compiling a .NET Core application, the output filename will be the project directory name. So if you are compiling the application from a directory abc, the output dll name will be abc.dll. This can cause an issue when using CI where you may not control the folder structure in which the command is executed. This can be fixed using buildOptions configuration in the project.json file.

Configuring Redis for ASP.NET Core Session Store

Posted by Anuraj on Monday, November 14, 2016

ASP.NET Core Redis Cache Session

This post is about Configuring Redis for ASP.NET Core Session Store. Redis is an open source (BSD licensed), in-memory data structure store, used as database, cache and message broker. It supports data structures such as strings, hashes, lists, sets, sorted sets with range queries. Redis works with an in-memory dataset. it also supports persisting the dataset to disk. Moreover, It provides master-slave asynchronous replication. Redis is not officially supported on windows. However, the Microsoft Open Tech group develops and maintains Windows port targeting Win64 available here. You can install redis using chocolatey package manager, using choco install redis-64 command. Once you install redis you can run redis-server command to start the redis server.

Working with client side packages in ASP.NET Core

Posted by Anuraj on Wednesday, November 9, 2016

ASP.NET Core Bower Javascript

This post is about working with client side packages in ASP.NET Core. In this post I am using Bower as client side package manager and dotnet bundle command for bundling and minification, instead of gulp or grunt. In ASP.NET world, we were using nuget for client side packages as well. Nuget is a good package manager for for .NET libraries and the Microsoft eco-system. But problem with Nuget is if someone writing a new Javascript libaray, you can’t expect them to create a nuget package and publish it. The web development world has largely settled on Bower as the defacto package manager for client side libraries. Bower is a “package manager for the web.” Bower lets you install and restore client-side packages, including JavaScript and CSS libraries. To use Bower, you need to install NodeJS first. You can download NodeJS from here.

Measuring code coverage of .NET Core applications

Posted by Anuraj on Sunday, November 6, 2016

C# ASP.NET Core Unit Testing Code Coverage .NET Core

This post is about getting code coverage of .NET Core using Opencover. This is an update post, long back I wrote a post on code coverage using ASP.NET Core in RC days. This post is using dotnet command and 1.0 version. Opencover is a code coverage tool for .NET 2 and above, support for 32 and 64 processes with both branch and sequence points; roots proudly based in PartCover - https://github.com/OpenCover/opencover/


Copyright © 2016 - Anuraj P. Blog content licensed under the Creative Commons CC BY 2.5 | Unless otherwise stated or granted, code samples licensed under the MIT license. This is a personal blog. The opinions expressed here represent my own and not those of my employer.