I have a silverlight-enabled WCF-service, of which one method absolutely requires the [STAOperationBehavior] attribute. I need to access user details (Forms Authentication) for the user, but Membership.GetUser() fails while the [STAOperationBehavior] attribute is applied.
i.e.
[STAOperationBehavior]
[OperationContract]
public string DoWork(int inputStuff)
{
Membership.GetUser();//Fails
}
but
//NOT ON STA THREAD
[OperationContract]
public string DoWork(int inputStuff)
{
Membership.GetUser();//Works
}
How can I access user information in this method, or otherwise provide this method with the user's information?
I eventually solved this by removing the STAOperationBehavior attribute and executing the method on an STA thread manually:
A bit messy but I found no other way of doing it