Archived articles - November 2018
Archive for November 2018 (8)
28
Nov
2018
Using DisplayName attribute for model validation output in ASP.NET MVC Core
.NET229 titlesReturning DisplayName attribute value in model validation response in MVC Core
0
Model validation is an important part of request life-cycle and pipeline in MVC Core regardless whether you are building Web API project or ASP.NET MVC web application. Both project templates rely on the common ASP.NET Core platform therefore validation is pretty much the same in both type of projects.
Because Web API and micro services are more popular nowadays, I am going to use Web API sample project to demonstrate how to modify validation response in MVC Web API Core project.
...read more
25
Nov
2018
Dependency injection with custom MVC filter attributes in ASP.NET Core
.NET229 titlesUsing dependency injection with custom ExceptionFilterAttribute in ASP.NET Core
0
Apart from adding your own middleware to the ASP.NET MVC Core application pipeline, you can control the response using custom MVC filter attributes and selectively apply them to either whole controller or controller actions.
One of the commonly used MVC filter in ASP.NET Core is ExceptionFilterAttribute for handling error response in Wep API applications. It is easy to implement and I also wrote an article about Error handling in ASP.NET Core Web API few months ago...read more
22
Nov
2018
Install multiple packages from Visual Studio package manager console
PowerShell24 titlesAdding multiple nuget packages to the project from package manager console
0
If you are using Visual Studio 2017 as your main IDE, than you are probably familiar and used at least once NuGet package manager console. You may know or maybe not, but NuGet Package Manager relies on PowerShell script and Package Manager Console is basically hosted PowerShell command line inside Visual Studio.
This means, apart from NuGet commands, you can also execute PowerShell commands. ...read more
21
Nov
2018
Adding healthchecks just got a lot easier in ASP.NET Core 2.2
.NET229 titlesSetting up and using healthcheck endpoints in ASP.NET Core 2.2
0
Health checks or health probes are the crucial part for orchestrating micro services. If you are using Kubernetes for orchestrating containerized application instances or you just have multiple ServiceApps or VMS behind the load balancer, you need to define health checks in order for the orchestrator or load balancer to know to which instance to send the traffic and to which not...read more
20
Nov
2018
Mocking IConfiguration GetValue<T> extension methods in Unit Test
.NET229 titlesHow to mock extension methods for IConfiguration in .NET Core
0
Now here is a trouble that was bugging me for some time and I guess who ever is using IConfigration injected in the constructor and using extension methods to access configuration values reached whan trying to write Unit Tests.
IConfiguration interface is a great way to easily replace your configuration layer in application, but it has it's drawbacks. The way interface envorces configuration reading is by exposing GetSection method which return IConfigurationSection...read more
13
Nov
2018
Tracking data changes with Entity Framework Core
.NET229 titlesHistory/Audit of data changes using Entity Framework Core
0
Tracing data changes can be beneficial in narrowing down the issue that may occur in production. If you are using Entity Framework Core you have several ways to store actions performed against your data...read more
11
Nov
2018
Handling data concurrency in EF Core and ASP.NET Core WebAPI
.NET229 titlesData concurrency in Entity Framework Core
0
Entity Framework Core implements optimistic concurrency strategy which is opposite to pessimistic concurrency strategy. Lets's first clear out what are main differences between these two approaches in concurrency control.
Optimistic concurrency control allows multiple processes to access and modify data without any explicit lock on the data...read more
04
Nov
2018
Setting up Swagger to support versioned API endpoints in ASP.NET Core
.NET229 titlesAdding Swagger support for versioned REST Web API endpoints
0
Versioning of your endpoints is important especially if you have 3rd party dependent clients of your REST API service. Any change in your endpoint, for example in data structure may impact clients even if it is backward compatible, clients may process your endpoint data in different ways, so even adding one additional property to your model may also impact functionality of the client which is consuming your endpoint.
Prerequisites
...read more
.NET
5
Jun
2022
Using dotnet nuget package vulnerability scan in Azure DevOps build
Listing nuget vulnerabilities and controlling build in Azure DevOps
5
May
2022
Protecting static files in ASP.NET Core using custom middleware
Restricting access to specific static content with middleware in ASP.NET Core
20
Dec
2021
Supporting multiple authentication schemes in asp.net core webapi
Using more than one authentication schemes in webapi projects
12
Dec
2021
Controlling the flow of migrations in EF Core
Altering EF Core migrations execution order
28
Nov
2021
Unit of work pattern with Dapper
Implementing unit of work pattern with Dapper in .NET 5
21
Sep
2021
Adding display name to Enum values
Implementing additional values for Enum items in C#
JavaScript
28
Oct
2018
HTML5 localStorage with expiry with vanilla JavaScript
Using HTML5 localStorage with expiry
8
May
2018
Monitoring DOM changes with JavaScript
Handling DOM changes with plain JavaScript
9
May
2017
Non blocking CSS load on the page
Load external CSS files in an async manner
16
Mar
2017
Serialize html form to JSON without using JQuery
Transform user input from HTML form fields to JSON
17
Jan
2016
Copy text value to clipboard using jQuery
Simple sample of using jQuery to copy value to clipboard
11
Jan
2016
Resize image on the client side with JQuery
Reducing the upload sie by resizing image on the client side
SQL/T-SQL
22
Feb
2022
Select column names with values from SQL Server database
Fetching column names with its value in T-SQL using built in JSON methods
23
May
2020
Identifying opened connections for the specific application in SQL Server
Connection listing queries in SQL Server
3
May
2018
Reading JSON data in T-SQL on SQL Server
Extracting values from JSON string on SQL Server using T-SQL
28
Apr
2016
Create XML/HTML with T-SQL
Generating XML/HTML output in SQL Server
24
Nov
2015
IP address to octets split in TSQL
Split IP addresse into octets in SQL Server
20
Jul
2015
Getting first and last second of the current year, month and day
Using minimum and maximum date time in SQL query
Umbraco CMS
2
Mar
2018
Minify HTML output of your pages
Minification of HTML output using ASP.NET IHttpModule
18
Apr
2015
Generate sitemap.xml on the fly in Umbraco CMS
Simple sitemap.xml Umbraco handler
2
Mar
2015
Accessing UmbracoHelper in HttpHandler request
Working with UmbracoHelper and IPublishedContent in HttpHandler
14
Sep
2014
Same page language switching in Umbraco
Land on the same page in different language in Umbraco using Relations
4
Sep
2014
Getting cropped image the smart way
The way to get cropped image URL with option to load original image too
27
Aug
2014
Fastest way to return JSON result from a controller
Resturn JSON in MVC controller action