Friday, March 30, 2007

Using Forms Authentication with Callbacks

We use callbacks all over the place in our applications. Because of
various security and technical concerns we also use forms authentication by
default. Well this creates a problem when the forms authentication ticket
expires. In the traditional model using postbacks when the authentication
ticket expires you are redirected to the login page however when a callback
occurs there is no action by default. After discovering this I began
googling for information and found this blog post
Admittedly it is a little hacky but I think it works well for our purpose.
Read the article, but the jist is this:

Micorsofts callback javascript handler expects a response that either begins
with an 's' for success or 'e' for error. The authentication failure does
not return either of these

To get around you add a handler for the Application_AuthenticateRequest
event in the global.asax. In the handler, write a message to the response
the begins with an 'e' then you can redirect to the login page from within
the the Callback error javascript.

Wednesday, March 14, 2007

Use Once Dialog

In my post on Handling alerts in WATIN
<> I
referenced a class called UseDialogOnce and did not show the code for it.
This is an adaptation of the one that is in the WATIN Unit tests file

using System;
using WatiN.Core;
using WatiN.Core.DialogHandlers;

namespace Framework.UnitTesting

public class UseDialogOnce : IDisposable
private DialogWatcher dialogWatcher;
private IDialogHandler dialogHandler;

public UseDialogOnce(DialogWatcher dialogWatcher,IDialogHandler
this.dialogWatcher = dialogWatcher;
this.dialogHandler = dialogHandler;

if (dialogWatcher != null)

#region IDisposable Members

public void Dispose()


protected virtual void Dispose(bool managedAndNative)

dialogWatcher = null;
dialogHandler = null;

Wednesday, March 07, 2007

NOVA Code Camp

There will be a Northern Virginia Code Camp on April 14