Web Log

Server-side, client-side, code snippets, scripts, automation, best practices, proven approaches, tips & tricks...

Getting GIF image information using C#

Extracting 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

How to avoid Thread.Sleep in your production code in .NET

Avoiding 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

Reduce traffic by serializing JSON with different alias with Json.NET and C#

Reducing 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

log4net logger for Microsoft Azure Log Analytics

Logging 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

Setting IP address and domain filtering in IIS using PowerShell script

Restricting 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

Handling Cross-Site Scripting (XSS) in ASP.NET MVC

Handling 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. It is ofter use to steal form inputs, cookie values, change the page layout or redirect to attackers website. ... read more

Optimize JPG images for internet using jpegtran and PowerShell

Reduce 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. Although I mostly use PNG images, there are still some JPEG images I use on the pages and this was not included in optimization with PNGCRUSH utility since it is specialized for PNG ... read more

Optimize PNG images for internet using pngcrush and PowerShell

Reduce 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. Now this can be solved thanks to a lot of online PNG image optimizers, but considering the number of the files you might have over the years of website running it can be matter of days, even maybe weeks to optimize all of them. This was my case and I could not afford myself that much time. ... read more

JavaScript

read more

Umbraco CMS

read more

.NET

read more

SQL/T-SQL

read more