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.