"Interesting" WAP quirk #87

by Ted Jardine Monday, January 15, 2007 1:26 PM

Anyone using WAP (Web Application Projects) for ASP.NET 2.0 development will know what I'm talking about here: you love it for some things (otherwise, why would you bother using it?), and will just shake your head at the time wasted trying to figure out its various little quirks. Peter (as usual) had an eloquent/insightful/as-usual-make-me-roll-on-the-ground-laughing way to describe WAP implementation the other day, but I can't remember it (perhaps he'll come up with one in the comments?). But here is quirk #87 (or whatever quirk we're up to now): I am attempting to change a Profile property in a WAP project following successful login. This works no problem in a typical Website Project, but in a WAP I get this: "This property cannot be set for anonymous users". Ummm, nooooo...the user is not anonymous as the only way to get here is if the user has successfully logged in. Googling brought up others with the problem, but no solution. So here I am to save your day (or at least brighten it up a little bit): private WebProfile profile; private WebProfile Profile { get { if (profile == null) profile = new WebProfile(Context.Profile); return profile; } } protected void LoginControl_LoggedIn(object sender, EventArgs e) { Profile.Initialize(LoginControl.UserName, true); Profile.PropertyYouWantToChange = "New Value"; Profile.Save(); // Note that you've got to save here if you turn Profile AutoSave off in the Web.config (recommended) } In retrospect, you can figure out why this rigamole is required (well, maybe), but it still shouldn't be that way. Oh well...I await some Tyrrellian Quote that will help us deal with the emotional pain.


blog comments powered by Disqus

Month List