How do you clear the thread principal in c#.
I have a background thread that does a
Membership.ValidateUser(username, password);
which then copies the resulting Principal back to the main thread
AppDomain.CurrentDomain.SetThreadPrincipal(Thread.CurrentPrincipal);
this works fine. But, if I log off I want to clear the principal, if I set it to null it does nothing Thread.CurrentPrincipal = null; if I try and set it again via
AppDomain.CurrentDomain.SetThreadPrincipal(Thread.CurrentPrincipal);
I get the error
Default principal object cannot be set twice.
Any ideas?