WebLog

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

SqlBulkCopy with model classes in C#

Use SqlBulkCopy with model (POCO) classes in C#
 
0
So far (based on my experience) the fastest way to insert big number of records from application to database is to use SqlBulkCopy. The downsize of this is that SqlBulkCopy uses DataTable instace as an input parameter which is not so convenient when dealing with models which are strongly typed and a lot more easy to use than iterating through the DataTable...read more

GoogleMaps route jQuery plugin

jQuery plugin for easily adding route map on your website
0
To make it easier for your customers to find your store location it is really important to show them where you are, but what can make even better impact is to show them where you are based on their current location and to guide them to you. GoogleMaps are a powerful tool for that, but you have to spend some time (more or less) to find code snippets and understand how to invoke their API, add the proper references, handle exceptions which might occur during the communication between your website and GoogleMaps API etc. ...read more

IP address to octets split in TSQL

Split IP addresse into octets in SQL Server
0
In case you need to handle IP addresses in SQL, they are not much useful as string values. To do anything with them rather then just storing and retrieving (checking the ranges for example) you need to split IP address to segments (octets). The following is modified method I run into online. ...read more

Debugging Windows Service application with console in C#

An easier way to debug and develop Windows Services
 
0
Developing Windows Service might a a real headache since you do not have any visual part to see the output. Even if you want to rely on Visual Studio debugger you need to install the service, stop it (if already running), deploy, start the service from Windows MMC and finally hook up Visual Studio to the running service process...read more

Non blocking writing to console in C#

Write message to console without blocking current thread
0
The fast and most commonly used method to debug code is for sure using console applications. Since main operations are reading input and writing output, it does not take much to set it up and start debugging your code. One more reason for using console application is to test the performance...read more

IP address filtering from C# code in ASP.NET MVC and Web Api

Restrict or allow specific IP addresses to access your WebApi or MVC
 
 
0
Last year I wrote an article about IP address filtering on MVC and WebApi Restrict Access to an MVC Action or Controller based on IP address. Over time the requirements for IP filtering in several web based application increased, so I had t work on this class to make it more extendible and reusable in different scenarios...read more

.NET managed scheduled task runner

Scheduled managed code execution in .NET
 
0
Sometime ago I wrote an article about Windows Scheduled Task vs Windows Service where I compared and listed benefits and drawbacks of using scheduled tasks in Windows and Windows Services for executing certain operation which repeats in some time span. However idea of executing tasks in a single Windows Service is very useful if you need to execute task in a short time span plus you have a full control including logging and other fine grained customization in case you write the task in your code...read more

MSMQ JSON message formatter

Use JSON to serialize and deserialize message queue messages
0
Storing objects in the message queue (MSMQ) is based on the serialization of the object instance using some of the serializes, basically any class the implements IMessageFormatter. Most commonly used ones are BinaryMessageFormatter and XmlMessageFormatter. I prefer XmlMessageFormatter over BinaryMessageFormatter, mostly because messages are stored in a readable format inside the queue, so in case something goes wrong you can direly check the content of the message using built Computer Management MMC (Microsoft management console) in the. ...read more

Multiple console output in C#

Write console output to file and screen at the same time
 
0
Console applications are the simplest one and very convenient when you need to quickly test some functionality. Some time the functionality that you test with console application may take time and since it is test usually it happens that it crashes...read more

Parse date of Facebook OpenGraph API response with JavasScript

Converting datetime string from Facebook API response to JavaScript Date object
0
Recently I had an issue while working on an update for my Facebook Album Browser plugin with dates returned from Facebook OpenGraph API. The dates are returned in the following form 2011-06-13T23:31:19+0000 and luckily for me, converting this string to an actual Date object in JavaScript worked pretty well for most of the browsers, but some of them like Safari on iPad did not know to convert this string to a Date object and because of that I was getting default JavaScript date 1970-01-01 00:00:00 UTC+00. After some time spent googling and checking regular expressions, I did not find a suitable solution for this. ...read more

JavaScript

read more

Umbraco CMS

read more

.NET

read more

SQL/T-SQL

read more