Friday, October 30, 2015

Using Google Tag Manager to deploy Azure Application Insights client-side monitoring

If your web application is hosted on Microsoft Azure and you are using Application Insights for monitoring you'll have to add a piece of JavaScript on web pages to collect client-side statistics like page load time, JavaScript errors, users and sessions analytics, etc. The script can be found on Azure portal when Application Insights is enabled for a web application and it should look similar to this (don't pay attention to formatting):

Standard Azure instruction says:
To collect end-user usage analytics about your application, insert the following script into each page you want to track. Place this code immediately before the closing tag, and before any other scripts. Your first data will appear automatically in just a few seconds.
The trouble with this is you may need to modify many web pages and then do the live deployment before any data will be collected, and then if you are not happy with something, repeat the cycle over again. It's time consuming and counter productive. What's the solution then?

You you already use Google Analytics on your web site you may be familiar with Google Tag Manager, aka GTM, if not Google it up. In short GTM allows dynamically adding random blocks of JavaScript on live web sites without making any changes to the code and control JavaScript block presence from the Web UI. Convenient, efficient, and provides good control.

In general GTM works out of the box with no or little troubleshooting required but some scripts may not work with it. Many script providers usually state their known compatibility level with GTM. Unfortunately Azure does not say in their documentation anything about GTM. Regardless, first it's worth a try, and secondly, it does work.

The Application Insights JavaScript for client-side analytics does work with Google Tag Manager and requires no changes nor troubleshooting. Clear pass. Give it a try and enjoy the ride.

Thursday, June 11, 2015

WebDav Client for Windows

Recently I've been involved in migrating JIRA Server to JIRA Cloud and one particular required step was to upload exported JIRA data files on to Atlassian cloud storage. Atlassian supports WebDav protocol but they have no suggestions about what client software to use most likely because of the large diversity of what operating systems their customers use.

I was working on Windows 8/Server 2012 and did not have previous experience nor preference for a particular WebDav client. Google search returns a number of choices on the first page but it's hard to pick one based just on reading so I ended up installing and trying a number of different software packages. Without further ado to save time to someone who is facing similar exercise my tool of choice happened to be BitKinex. Extremely easy and intuitive to use, works immediately with no additional configuration, and provides familiar Windows Explorer user experience with drag and drop support. Thumbs up!

Tuesday, May 5, 2015

Controlling console output from a windows task

Windows tasks continue to be very handy especially for automating batch operations that do not require constant human attention. But even such operations may require occasional human interference to troubleshoot problems.

Most of the Windows tasks execute command line programs that do not have graphical user interface but produce output in form of log files or console messages. While monitoring of log files can be relatively easy automated via different kinds of log collection services, the console output that is mostly meant for human eyes and could provide helpful information is usually lost as by default Windows task does not save console output anywhere.

There is however a relatively easy way to save console output produced by a Windows task in a text file. Windows command line environment provides with a function to redirect standard program output to stdout or stderr to a file using redirection commands '>' or '>>'. The first one redirects that output to a file and replaces the file if it exists with a new version and the second one appends the output to a file if it exists.

In order to use output redirection a Windows task action should be configured to execute a CMD shell instead of an actual cl program. So instead of

>myprogram.exe > output.txt

it should be configured as

>CMD /C "myprogram.exe" > output.txt

In the first example of direct calling a program Windows task will ignore output redirection and the entire output will not be saved. In the second example the redirection will be executed not by a Windows task but by a CMD shell instead and the output will be saved in a file.

Friday, September 19, 2014

404 Error in IIS for a Url with a plus + in the Path

Default Internet Information Server (IIS) behavior since IIS 7 rejects requests to Urls with a plus (+) sing in the path like: or

The behavior is considered a security feature and controlled by a setting called "Double Escaping Filtering". To override the default rejecting behavior the setting needs to be changed either via a web.config configuration:

or an IIS Management user interface:

Thursday, August 28, 2014

External Social Login/Authentication with Microsoft ASP.NET Identity Does Not Work

Well, it's painful as hell, when you spend many days developing custom implementation of ASP.NET Identity with a main goal to enable social/external authentication (as in Facebook, Google, Twitter, etc.) and at the end everything works but the social authentication itself.

The main reason of it not working is that inside ExternalLogin (or similarly named) action method of an Account controller the external login info object is always null:

Google search returns a lot of discussions on Stack Overflow and it takes a lot of time to go through them but eventually you'll find out (and will be very disappointed) that if you did everything right with your Identity implementation and did not make any stupid mishaps than it's totally not your fault and there is almost nothing in answers on Stack Overflow for you to figure out the problem.

Apparently it's an OWIN bug that is still not fixed (I tested with both Identity 2.0.x and 2.1 and it's still there and happening) as it was figured by smart people ( and without going into obscure details there is a simple fix for it.

In a Login (or named similarly) action method (GET version) of your Account controller add the very first line of code as below:

The most disappointing part of this problem is that it will not necessarily surface while you are testing. First everything might work just fine and than suddenly out of thin air without any obvious reason it will stop working completely. If it's the case (you had it working and than it stopped) than this is your solution: just add that dummy code line as above and it will do the magic.

Let's see how long it will take Microsoft to fix this bug. Happy coding and thanks all the smart people for sharing their findings.