Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 555973
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T11:52:16+00:00 2026-05-13T11:52:16+00:00

I have two domains, domain1.com and domain2.com pointing at the same asp.net website which

  • 0

I have two domains, domain1.com and domain2.com pointing at the same asp.net website which uses asp.net build in form authentication. The problem is that even if the domains point to the same website the user only get authenticated for one domain at a time. So if he uses http://www.domain1.com first and then visits http://www.domain2.com it’s the same website in the back but he only is authenticated for http://www.domain1.com. The same thing happens if he uses www and not www when visiting the sites.

This is what I use to login:

FormsAuthentication.RedirectFromLoginPage(username, cookie.Checked);

To check login:

User.Identity.IsAuthenticated

How can I make the user gets authenticated for all domains that points to the same website?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T11:52:16+00:00Added an answer on May 13, 2026 at 11:52 am

    What you’re after is a Single Sign-on solution.

    As ASP.NET authentication is at it’s heart generally cookie based, there are two things to look at:

    1. Set your cookies correctly.
    2. Bounce your users to the alternative domain during signup.

    Looking at both of these in more depth:

    1. Setting cookies correctly

    You need to ensure that ASP.NET is writing the authentication ticket cookies to the root domain, rather than the explicit domain this is done using the domain attribute of the forms element:

    <forms 
       name="name" 
       loginUrl="URL" 
       defaultUrl="URL"
       domain=".example.com">
    </forms>
    

    You should set your domain to “.example.com” – note the leading period – this is the key. This way requests to example.com and http://www.example.com will both read the cookie correctly, and authenticate the user.

    2. Bounce users to the alternative domain

    What we have implemented on a few sites that use a single sign on is a round trip login process. The user authenticates on the first domain, we encrypt the login details, and redirect them to a known page on the second domain, log them in there, and then redirect back to the original server.

    This client side redirection is important – cookies are only written when there is a response back to the client, and the browser has to visit the second domain to actually see the cookies.

    Other details to consider in this sort of set-up:

    1. You probably want to have a timeout on the encrypted sign-in details – so that recalling that URL from the browser history doesn’t automatically log the user in.
    2. If the domains are on different servers, you will need to ensure that either the machine keys are configured the same, so that you can encrypt and decrypt the details correctly, or use some other shared key.
    3. You will probably want to have a mechanism in place to recall the users ReturnUrl from the original server so that you can send them back to the correct place.

    You could also take a look at “Forms Authentication Across Applications”

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two insert statements, almost exactly the same, which run in two different
I have two versions of the same proof-of-concept site: The unsecure version: http://www.tlsadmin.com/tlsadmin/PortalHome.aspx and
I have two domains, one is a .com domain and the other is a
I have a .net webapplication with the following domains: www.domain.com sub.domain.com files.domain.com When a
i have to write htaccess for mysite. actually we have two domains. '.com and
I have two arrays of System.Data.DataRow objects which I want to compare. The rows
I have two webapplication, one is a simple authenticationsite which can authenticate the logged
I have the following task: Create one website which is accessible with 20 different
I have a login.jsp page which contains a login form. Once logged in the
I have two subdomains pointing to the web directory in my Symfony 1.4 implementation

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.