Archived articles - March 2018
Archive for March 2018 (15)
28
Mar
2018
Getting GIF image information using C#
.NET229 titlesExtracting GIF image data in .NET using C#
0
GIF image format is most commonly used format for online advertising, especially since all browser starting from major onces stopped supporting Flash animations because of their infamous security vulnerabilities and issues. After going through different articles I found online, I came up with the class which exposes following GIF image properties...read more
25
Mar
2018
How to avoid Thread.Sleep in your production code in .NET
.NET229 titlesAvoiding Thread.Sleep in production code in .NET using C#
0
I am pretty sure any of us used Thread.Sleep method to pause the current thread execution. Mostly this is used to simulate long running process during the test or debug.
While this is fine to use for testing, if your intention is to actually schedule thread execution this is probably wrong way of doing it, simply because Thread.Sleep does not actually take as many milliseconds as you pass to the method as a parameter...read more
23
Mar
2018
Reduce traffic by serializing JSON with different alias with Json.NET and C#
.NET229 titlesReducing speed and increasing performance by reducing traffic with JSON size
0
One of the reasons JSON is used rather than XML is it's simplicity in notation. However XML is claimed to be more human readable than JSON and JSON is easier to parse for machines, so basically we switched from XML in favor to machine processing.
If you take a C# class and serialize it to JSON string you still find it quite readable since we kept all nice property names in the JSON output...read more
18
Mar
2018
log4net logger for Microsoft Azure Log Analytics
.NET229 titlesLogging to Azure Log Analytics using log4net
0
Recently I wrote an article on how to Send data to Azure Log Analytics from C# code which is demonstrating pushing data from your code to Microsoft Azure Log Analytics and simple quering the data from the Log Analytics. Azure Log Analytics are extremely helpful for storing application logs because they provide transformation of the raw data into queriable columns, you can easily query your logs stored in Log Analytics and export to Excel format if you need to share the data or you just want to make some offline data analysis...read more
17
Mar
2018
Setting IP address and domain filtering in IIS using PowerShell script
PowerShell24 titlesRestricting and allowing traffic to web application through IIS using PowerShell
0
Starting from IIS 7.0 Microsoft introduced IP and Domain restrictions feature as a part of IIS setup. However, if you do not have this feature installed on your IIS you can easily install it through windows features adding steps which are pretty much same for each Windows version (https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/ipsecurity/add) or simply by using WebPlatform Installer.
Just run WebPlatform Installer and search for IP and Domain restrictions in search box...read more
14
Mar
2018
Download file in chunks in parallel in C#
.NET229 titlesImproved file download using chunks of file in parallel in C#
0
Downloading large files from your code may cause problems due to limitations in your network or system where your code is executing. For example, some systems limit the size of the file you can download through the network...read more
13
Mar
2018
Displaying multiple select input for Enum in Swagger WebApi UI
.NET229 titlesMultiple select input Swagger WebApi UI
0
Enums in C# can contain multiple values if they are decorated with [Flags] attribute. However, Flag Enums are not recommended to be used in web api action method signatures...read more
08
Mar
2018
Handling Cross-Site Scripting (XSS) in ASP.NET MVC
.NET229 titlesHandling XSS in ASP.NET MVC with custom Razor Html helpers and HttpModule
0
Cross-site Scripting (XSS) refers to client-site code injection attack where an attacker can execute malicious scripts into a web application. Basically attacker manages to upload malicious script code to the website which will be later on served to the users and executed in their browser...read more
07
Mar
2018
Using WebP Images in APS.NET with a fallback to JPEG and PNG
.NET229 titlesWebP images in ASP.NET with fallback for browsers not supporting WebP
0
WebP is an image format introduced by Google Developers and it provides superior lossless and lossy compression for images on the web. Using WebP, webmasters and web developers can create smaller, richer images that make the web faster...read more
06
Mar
2018
Converting existing website images to Google WebP using PowerShell
PowerShell24 titlesEncoding existing image files to Google WebP format
0
WebP is an image format introduced by Google in 2010. It uses specific technique to compress image and reduce size significantly while not changing the image quality on the larger scale...read more
06
Mar
2018
Optimize JPG images for internet using jpegtran and PowerShell
PowerShell24 titlesReduce size of existing JPG images without loosing quality with jpegtran
0
Recently I wrote an article about optimizing PNG images for intenrent using pngcrush and PowerShell. I actually used this method to optimize all PNG images on my website...read more
05
Mar
2018
Optimize PNG images for internet using pngcrush and PowerShell
PowerShell24 titlesReduce size of existing PNG images without loosing quality with pngcrush
0
Imagine a case where you have an existing website which is running for the past few years. You decided to run a Google PageSpeed insights on couple of pages and you realized that your PNG images on the pages are not optimized for Internet...read more
04
Mar
2018
Minify CSS and JavaScript files with PowerShell script
PowerShell24 titlesJavaScript and CSS file optimization with PowerShell script
0
Minification of Cascade Style Sheet (CSS) and Java Script (JS) should be on a TODO list for every web application. The minification of CSS and JS can be easily one on the runtime with ASP.NET bundling which is build in in ASP.NET framework, but in case of distributing your resource files over CDN you cannot use the runtime minification. You physical files need to be minified...read more
03
Mar
2018
Switch from HTTP to HTTPS in existing ASP.NET web application
.NET229 titlesSwitch complete traffic from unsecured to secured with web.config update
0
Starting from few years ago, Google enforces secured over unsecured website traffic. However it is an ongoing process since both publishers and advertisers need to implement HTTPS in order to avoid mixed contnet exception in a browser and preventing ads to load on a website.
...read more
02
Mar
2018
Minify HTML output of your pages
Umbraco CMS25 titlesMinification of HTML output using ASP.NET IHttpModule
0
Minification of resource can speed up your page load and decrease network traffic making you pages load faster, especially on a poor Internet connections. Keep in mind that not all of your website visitors have high speed Internet connection...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