Sunday, December 11, 2016

Azure returning a 404 for woff files

This is actually a configuration error, as described here

The solution was to add the following to the web.config:

      <mimeMap fileExtension="woff" mimeType="application/font-woff" />
      <mimeMap fileExtension="woff2" mimeType="application/font-woff" /> 


Thursday, September 15, 2016

OpenVPN not changing my IP address

When I installed the OpenVPN client and connected to a VPN it changed my IP address correctly. However, subsequent times it didn't change it. It turned out I had to run the application as an administrator, and that was it.

Monday, June 27, 2016

How to return a 401 status code using ASP.NET MVC 5 and OWIN

This time I was trying to force users to the login page after an Ajax request failed because of an expired session. I was getting something like this in the response:

X-Responded-JSON: {"status":401,"headers":...
I investigated a little and turned out you have to add this code to your Startup.Auth.cs file:

Provider = new CookieAuthenticationProvider
  OnApplyRedirect = ctx =>
    if (!IsAjaxRequest(ctx.Request))

Also, in your filter I suggest you do something like this:

if (filterContext.HttpContext.Request.IsAjaxRequest())
filterContext.HttpContext.Items["RequestWasNotAuthorized"] = true;
filterContext.HttpContext.Response.StatusCode = 401;
filterContext.Result = new HttpUnauthorizedResult();

And then handle it in JavaScript like this:

$(document).ajaxError(function (xhr, props) {
if (props.status === 401) {

More information on the error can be found here:

Wednesday, June 15, 2016

A connection was successfully established with the server, but then an error occurred during the login process. (provider: Shared Memory Provider, error: 0 - The handle is invalid.)

The solution is simple, just reset IIS. If that doesn't work, this SO question will help

Sunday, May 15, 2016

Run Visual Studio as an administrator all the time

Why is it that right-clicking the Visual Studio icon and then clicking Visual studio opens the application as an administrator (after you configure it this way in the properties window) but right-clicking the Visual Studio icon and then clicking a project doesn't? In Windows 8 and 10 you have to follow a few more steps as defined here (

Right-click devenv.exe and select "Troubleshoot compatibility".
  1. select "Troubleshoot program"
  2. check "The program requires additional permissions" click "Next", click "Test the program..."
  3. wait for the program to launch
  4. click "Next"
  5. select "Yes, save these settings for this program"
  6. click "Close"

Wednesday, April 13, 2016

Entity Framework - Store update, insert, or delete statement affected an unexpected number of rows (0)

This error can have several causes, in my case it was that I had forgotten to create the PK and identity columns in a table. More complex causes can be found here

Saturday, April 9, 2016

PowerShell - "AuthorizationManager check failed" from Octopus Deploy

I came across this error when trying to run Import-Module in an Octopus Deploy PowerShell script. This script was in the source code. What I end up doing was taking out Import-Module into its own Octopus Deploy step "Run a Script".

This article also thoroughly explain the reason for the error

In the process, I also learned that Octopus Deploy changes the execution policy of the Powershell process to unrestricted.

Wednesday, April 6, 2016

Tracking changes in a database in a .NET project

Java has a very neat package to do this, called torque. In .NET we're not quite there yet, so I highly recommend for .NET projects. Here are some things to keep in mind:

1) It will log all changes into only 2 (master-detail) tables (instead of having as many tables as entities as in torque).
2) You need to create those 2 tables manually, the schema is derived from screenshots in the wiki of the project (don't forget your PK's).
3) Setting it up is quite simple, only annotate the entities you want to track and inherit from TrackerContext instead of DbContext.

Saturday, March 12, 2016

Debugging minified code in Chrome's Developer Tools

There are 2 options. The first one is really simple, just go to Developer Tools > Sources > Find the minified script > Click it to open it > Click the {} button on the bottom-left corner of the script. That is going to un-minify the script. In other words, it's going to add a carriage return to make it readable but will still be the same file contents.

The second option is to use the Workspace of the Developer Tools. You can read more about it here

Sunday, March 6, 2016

Version control for your database in a Java project


I highly recommend it. This is the technology used in the project I'm currently working on (

Saturday, March 5, 2016

Intellij vs Netbeans vs JRebel

After 6 months of using Java (2 of them with Netbeans and 4 of them with IntelliJ) in an enterprise application, I highly recommend IntelliJ if you want to improve your productivity (if your application is small then IntelliJ might not be necessary).

Netbeans offers a good start but once you're proficient, you find that deploying your enterprise application to review your changes just takes too long. IntelliJ offers hotswapping and yes, you can do hotswapping with Netbeans ( because hotswapping exists natively in Java, but sometimes it doesn't work. That's because you need to use a specific Java version. I had it configured and it worked ok but when I upgraded Java it stopped working.

With IntelliJ hotswapping is already built into the IDE. You don't need to do any configuration. Just keep in mind that with IntelliJ hotswapping doesn't work when you change a method signature.

Still, you can take it one step further with JRebel. However, JRebel gave me a lot of problems so I uninstalled it. My main issue was that the page would take forever to load after a few hotswaps.

In summary, I recommend using IntelliJ for your Java development.

Wednesday, March 2, 2016

Microsoft Excel cannot open or save any more documents because there is not enough available memory or disk space

There are several things you can try, what worked for me is doing the following:

File > Options > Trust Center > Trust Center Settings > Protected View > Uncheck all options

Saturday, February 20, 2016

Java Hibernate "org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags"

There are a couple ways to fix it. Using Set instead of List is better than changing the fetch type to Lazy. You can find more information about that here in SO

Saturday, January 23, 2016

OmniSharp server is not running when taking Visual Studio Code for a spin in OS X

This happened to me when using Visual Studio Code in OS X. After typing Cmd + Shift + P and then dnx to Restore Packages, I got "OmniSharp server is not running".

This is most likely because your project.json file has errors. Open the Output console (Cmd + Shift + U) to get more information. Also, look at the errors in the Terminal when it opens. In my case the error was because of a comment in the project.json (using the double slash // which I had to remove). Another error I had was this line:

"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-update1"

which I had to change to:

"Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final"

Saturday, January 16, 2016

Setting up a dark theme in NetBeans

Lately I have found myself doing Java development. The default theme is white, but you can change it to dark, similar as in Visual Studio.

First download the theme from here:

Then install it following these instructions: