ASP.NET Membership Log Out

My boss likes to say “never use the words ‘simple’ or ‘easy’ in our line of work” and today was one of those days that demonstrates exactly why he loves this saying.

We were asked to setup an auto logout feature that redirects to the login screen. I’ve done so much Windows Authentication work that I’ve never actually had to build this functionality. I went straight to my favorite search engine and I found the following code.


Everyone was commenting about how this worked great and lo and behold it wasn’t working. More research and I found an article that explained that the above neglected to clear cookies sometimes and that to 100% ensure a sign out you should clear the forms authentication and session cookies.

The following code is what I ended up using in our application. It only expires the cookies that are forms authentication and session related.


var cookies = new List<string>

foreach (var cookie in cookies)
    if (Request.Cookies.AllKeys.Contains(cookie))
        Request.Cookies[cookie].Expires = DateTime.Now.AddYears(-1);


What Tools Do I Use?

At Houston TechFest 2013, Claudio Lassala presented “Want to Build Software? Get Your Act Together First!“. It got me thinking about how I work and what software I would recommend. The following tools fit into two categories. I either use it daily or it’s invaluable in specific situations (for example, taking screenshots or giving presentations).

The Data I Need When I Need It

I use a combination of three pieces of software to ensure that I always have all of the information I need at my fingertips. The three are: SkyDrive, OneNote, and KeePass.

SkyDrive is the Microsoft DropBox competitor. I use it for a 2 reasons. The first reason is it that it offers more storage for free. SkyDrive gives 7 GB while DropBox gives 2 GB. I actually have 25 GB due to an old SkyDrive promotion. The second reason is that I can view and edit all of my files directly through a browser. This has become extremely important to me. For example, I was recently in a meeting and a presentation that I was working on came up. I didn’t have my laptop but the meeting room had a computer connected to the screen. I was able to log into my SkyDrive and review the presentation directly from my SkyDrive.

OneNote is Microsoft’s note taking software. Evernote is a popular competitor and one that I have tried before. When OneNote was released for my mobile platform, I immediately switched back. Now I have access to my notes anywhere I have my phone or have access to an internet browser (I can view and edit my OneNote notebooks through SkyDrive).

KeePass is a password manager tool. We have passwords for everything now and they should all be unique and varied. How does it work? You create one password for your encrypted KeePass file and you place all of your other passwords into the file.


I currently work on a distributed team so having effective tools in place for collaboration and communication is a must.

For task and backlog tracking, we use Team Foundation Server. If TFS wouldn’t be available, I would be using Trello or a tool with similar features.

For voice, we use Skype. It’s simple, effective, and proven. Its screen sharing feature comes in handy if it’s just a quick discussion. For more complex screen sharing, we use TeamViewer. TeamViewer allows users to pass control around. This comes in extremely handy when working through code with another developer. Another plus is that TeamViewer has official apps for Android, Windows 8, Windows Phone 8, and iOS.

Let’s Develop Something Already!

I have already mentioned that I work in a Microsoft development team so Visual Studio is a must. I currently have 2010 and 2012 installed on my machine but we will be moving everything to 2013 on its release. If you’d like to know which plugins I’m using for Visual Studio, see my post “Visual Studio Add-ons“.

Everyone has their own favorite text editor and mine is Notepad++. It’s always the first thing that I install on a new machine and I immediately set it as my default text viewer. I’ve recommended it to every developer friend that I know. It has lots of goodies throughout the program including plugins. For example, the Compare plugin has taken the place of WinMerge on my machines and ToolBucket let’s me easily generate GUIDs and lorem ipsum, encode/decode to base 64, and more.

A great tool for testing .NET code snippets, LINQ statements, etc. is LINQPad. This little application is extremely feature packed and you’ll find more ways to use it every time you open it. One of my favorites is the ability to generate the SQL for a LINQ statement.

IETester by DebugBar is a must have for web developers wanting to test their website’s rendering in multiple IE versions.

Greenshot is my go to application for screenshots. It has multiple capture modes and a built in image editor which allows you to edit an image before saving the final version.

Presentation Must Haves

If you’re giving presentations or sharing screens often, I have a couple of recommendations.

The first suggestion is Key Jedi. Presenters tend to forget that the viewers don’t know when you press Alt, Ctrl, etc. This is a little application displays those special combination keystrokes so that your audience doesn’t get lost when you’re flying around Visual Studio using only the keyboard.

The second is ZoomIt. This application allows you to Zoom in and out of any application running in Windows. It also has some markup features which are quite nice once you get used to the keyboard shortcuts.