Archived articles - May 2018
Archive for May 2018 (11)
30
May
2018
How to setup .NET Core 2 on Debian or Ubuntu Linux distro the easy way
.NET229 titlesInstalling .NET Core on Linux the short way
0
Many of you who had chance to work docker and .NET Cote on Linux will agree that easiest way of running .NET Core on Linux is to pull microsoft/aspnetcore:2.0 image from docker repository and just setup your app with .Dockerfile.
You will be saved of the hassle of setting up the environment and .NET Core on on the Linux machine. But what if that is not an option? What if you really need for some reason to run your application on the specific host and not in the container?
...read more
29
May
2018
Google Invisible reCAPTCHA and reCAPTCHA v2 in ASP.NET Core
.NET229 titlesASP.NET Core implementation of Google reCAPTCHA and reCAPTCHA v2
0
Recently I wrote and article about setting up and using Google reCAPTCHA v2, better known as "I'm not a robot" validation. If you were setting up reCAPTCHA v2, you probably noticed that there is an option for "Invisible reCAPTCHA" option.
This type of validation, instead of asking user to interact with the UI in order to be identified as a human, does not require any direct interaction which can help building better user experience for your visitors...read more
24
May
2018
Using Google reCAPTCHA v2 in ASP.NET Core Web Application
.NET229 titlesValidating data with Google reCAPTCHA v2 in ASP.NET Core using custom validation attribute
0
In case you have any page on your website which allows anonymous users to POST data to your web application, you should always use any kind of bot protection. Usually that is any kind of CAPTCHA implementation...read more
23
May
2018
Redis health check in ASP.NET Core WebApi
.NET229 titlesChecking availability of distributed Redis cache instances in ASP.NET Core WebApi
0
Even before popularity of micro service approach, for even monolithic applications you needed to have health-checks (Google Compute Engine) or health-probes (Microsoft Azure) for load balancing.
Basically in load balancing scenario, these endpoints are used to tell load balancer whether instance can handle requests or not. Since handling of requests may consider several components, these endpoints either return 200 OK HTTP response or any other response like 500 Internal Server Error with optional payload message describing the issue and each component status.
...read more
22
May
2018
Using strongly typed objects with IDistributedCache instead of byte arrays
.NET229 titlesAn easy way to cache any object to distributed cache store using .NET Core
0
Saving an object to distributed cache store in .NET Core requires your object to be serialized to byte array in order for SetAsync method on Microsoft.Extensions.Caching.Distributed.IDistributedCache interface implemented instance to save your object to the injected cache store instance.
This means that what ever instance you have, you need to serialize it first to byte array. Similar, just reversed process applies for the process of reading an object from the distributed cache store.
...read more
18
May
2018
Seeding data in Entity Framework Core from Visual Studio
.NET229 titlesInsert sample data from Visual Studio IDE with EF core
0
Unlike Entity Framework 6, EF Core and whole .NET Core relies on dependency injection. For example, configuration is expected to be injected from the calling assembly instead of being available at any time...read more
15
May
2018
Error handling in ASP.NET Core Web API
.NET229 titlesGenerating the proper response for exceptions in ASP.NET Core WepApi
0
Both Web API in .NET 4.5 and later and Web API in ASP.NET CORE have great error handling support out of the box. You can specify you global handler and control your response to a client when exception happens.
...read more
13
May
2018
SETNX with TTL in .NET using StackExchange.Redis
.NET229 titlesSet key if it does not exist in redis with expiry using StackExchange.Redis
0
Recently I needed to set redis key if it is not present with specific expiry time to use it as some logical flag.
I knew tat you can use SETNX command for this but did not have any info how to set the expiry time. After some time going through redis documentation and articles found online I found a SET method overload for the redis-cli.
...read more
08
May
2018
Monitoring DOM changes with JavaScript
JavaScript31 titlesHandling DOM changes with plain JavaScript
0
If you are dealing with pure JavaScript without using any library, you probably want to trigger your custom actions on some element event. This is easily done with addEventListener which is in general supported by all now days browsers. ...read more
03
May
2018
Reading JSON data in T-SQL on SQL Server
SQL/T-SQL10 titlesExtracting values from JSON string on SQL Server using T-SQL
0
JSON is the most commonly used data fromat nowdays. It is lighter than XML, more readable and it's sindax complies with most OOP C-Like lnguages such as Java, JavaScript and C#.
There is not really many downsides of using JSON, so that is one of the rasons everyone is using it in one way or another.
...read more
02
May
2018
Generic string to primitive type converter in C#
.NET229 titlesConverting string data to any primitive type in .NET and .NET Core
0
Often case when you need to convert String to a different type which is most of the time a primitive type in C# is when you are reading values from configuration. In both .NET and .NET Core, reading from configuration return plain String value...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