vb.net .aspxauth

Posted by Morgan on Stack Overflow See other posts from Stack Overflow or by Morgan
Published on 2009-11-25T15:11:56Z Indexed on 2010/05/15 23:10 UTC
Read the original article Hit count: 447

I am working with a large site trying to implement web parts for particular users in a particular subdirectory but I can't get the .ASPXAUTH cookie to be recognized. I've read dozens of tutorials and MS class library pages that tell me how it should work to no avail. I am brand new to Web parts, so I'm sorry if I'm unclear.

The idea is that logged in users can travel the site, but then when they go to their dashboard, they are programmatically authenticated using Membership and FormsAuthentication to pull up their Personalization.

When I step through the code, I can see the cookie being set, and that it exists on the following page, but Membership.GetUser() and User.Identity are both empty. I know the user exists because I created it programmatically using Membership.CreateUser() and I can see it when I do Membership.GetAllUsers() and it's online when i use Membership.GetUser(username) but the Personalization doesn't work.

Right now, I'm just trying to get the proof of concept going. I've tried creating the ticket and cookie myself, and also using SetAuthCookie() (code follows). I really just need a clue as to what to look for.

Here's the "login" page...

  If Membership.ValidateUser(testusername, testpassword) Then   -- Works
        FormsAuthentication.SetAuthCookie(testusername, true)
        Response.Redirect("webpartsdemo1.aspx", False)
  End If

And the next page (webpartsdemo1.aspx)

Dim cookey As String = ".ASPXAUTH"
lblContent.Text &= "<br><br>" & Request.Cookies(cookey).Name & " Details"
lblContent.Text &= "<br>path = " & Request.Cookies(cookey).Path
lblContent.Text &= "<br>domain = " & Request.Cookies(cookey).Domain
lblContent.Text &= "<br>expires = " & Request.Cookies(cookey).Expires
lblContent.Text &= "<br>Secure only? " & Request.Cookies(cookey).Secure
lblContent.Text &= "<br>HTTP only? = " & Request.Cookies(cookey).HttpOnly
lblContent.Text &= "<br>Has subkeys? " & Request.Cookies(cookey).HasKeys

lblContent.Text &= "<br/><br/>request authenticated? " & Request.IsAuthenticated.ToString
lblContent.Text &= " Getting user<br/>Current User: "

Dim muGidget As MembershipUser
If Request.IsAuthenticated Then
     muGidget = Membership.GetUser
     lblContent.Text &= Membership.GetUser().UserName
Else
     lblContent.Text &= "none found"
End If

Output:

.ASPXAUTH Details
path = /
domain = 
expires = 12:00:00 AM
Secure only? False
HTTP only? = False
Has subkeys? False

request authenticated? False Getting user
Current User: none found

Sorry to go on so long. Thanks for any help you can provide.

© Stack Overflow or respective owner

Related posts about vb.net

Related posts about forms-authentication