FormsAuthentication.SetAuthCookie issue with domains w/o www

F

fadi

Hopefully someone seen this and knows best way around it.

When using FormsAuthentication and using FormsAuthentication.SetAuthCookie,
ASP.NET creates a cookie similar to the domain URL. For example, if the user
navigates to www.domain.com and logs in, then the cookie is associated with
www.domain.com. Even though the user is authentication to the domain, if a
link on the site goes to domain.com (without the www), the user is prompted
to login again!

I was trying to detect the domain the user is hitting using the URI object,
but the URI object tends to return domain.com rather than www.domain.com at
times even though the user navigated to www.domain.com and that is causing
my application to misbehave due to the cookie issue.

Here is an example of the problem:

Go to http://www.asp.net/PortalStarterKit/DesktopDefault.aspx that is
Microsoft's starterkit.
Login to the site and make sure you are logged in
Change the URL to http://asp.net/PortalStarterKit/DesktopDefault.aspx and
you will notice that you are no longer authenticated
change it back to http://www.asp.net/PortalStarterKit/DesktopDefault.aspx
and your authentication is picked up.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,045
Latest member
DRCM

Latest Threads

Top