Archive for pjsen

Quick-tip: Using newest Entity Framework assembly in ASP.NET MVC 4

For me it has been kind of unexpected behavior. When I update NuGet package, I get newest Entity Framework binaries. Today it is version 5.0. However, default MVC template targets .NET version 4.0. Newest version of Entity Framework for .NET 4.0 is 4.4. The NuGet package contains both assemblies, but the project will use 4.4 because the project targets .NET 4.0 by default. Furthermore, simply changing target runtime version in project properties is not enough. What finally has worked for me was manually editing .csproj file. I located assembly reference in XML and changed path in HintPath tag from \lib\net40\EntityFramework.dll to \lib\net45\EntityFramework.dll. The conclusion is to pay close attention to what particular version of assembly is actually being referenced and not relying only on NuGet versioning.

Start your own service detecting if an e-mail was read

I have come up with the idea after trying out bananatag.com which is such tracking service. Their solution is simple: let’s attach small, one-pixel image to an e-mail and log when it was downloaded. Providing that getting an image happened exactly when a user opens an e-mail.

What concerns me is the way the idea is implemented. They provide dedicated browser extension working with GMail or MS Outlook extension. So far so good, but if you use neither of these you have to “sync” your Banatag account with your e-mail account. It boils down to simply giving your log-in and password information to Bananatag. Then they act as a proxy for sending e-mails and they attach appropriate images on the fly.

Both solutions sound not so good to me. I prefer not to install many extenstions to keep my software installations as lightweight as possible. I typically work on more than one machine and installing extensions is not always possible. Last but not least, giving my credentials to some company is unacceptable from security point of view.

However, the idea is so simple that it is possible almost for everyone to start up completely own tracking web application. In this post I provide complete instructions as well as small, self-contained source code written in pure ASP.NET without any external dependencies.

First, you need free web hosting provider supporting ASP.NET. I have come across somee.com which seems to be fairly good. They offer 150MB space and require you to access web page at last once a month. After signing up and creating new web site you end up with address like http://(yourname).somee.com. Then you can download source code from my Skydrive which is pr.ashx. It stands for pixel recorder, because it is an application which serves one pixel image and records each event in randomly named text file. Simply upload that file into the root of your newly created somee.com account. Now you can access it from the Internet typing http://(yourname).somee.com/pr.ashx.

When the application starts for the first time it creates uniquely named text file and provides a link to it. Now you can start using it. When you are writing an e-mail insert an image from a URL to have it tracked. Please make sure that you force your e-mail composing app not to attach image to the message body, but rather to preserve the reference to your web application serving the image. The URL is as simple as this: http://(yourname).somee.com/pr.ashx?token=1. Where token is a number between 1 and 100. You can further adjust the range in source code. Now every time someone attempts to access this URL, one-pixel image is served and the time stamp is written into unique text file. You can use it from anywhere in any e-mail composing app, web mail or desktop. You can view your log and check from anywhere using any web browser whether an e-mail have already been read. Just remember what token number was associated with particular message and keep in mind some e-mail providers do not download any images by default (e.g. GMail — user has to click button to download any images included in the message body). Have fun!

Hello world!

Welcome to my main technical blog! Recently I have decided to diverge my concept of blogging. On this blog I will publish all new technical articles only in English. My old blog — pjs.blox.pl still exists, but only less important, Polish-specific articles will be published there. There are several reasons why I decided to build a new blog. Firstly, target audience is incomparably bigger for English content. Secondly, the old platform — blox.pl is real pain in the neck. It has many limitations and it is just inconvenient. Therefore, installing and starting own, decent platform such as WordPress is an obvious choice for any non-amateur writer.