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 6329877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T17:45:37+00:00 2026-05-24T17:45:37+00:00

I have two MVC3 sites, both hosted on the same server that I’ve configured

  • 0

I have two MVC3 sites, both hosted on the same server that I’ve configured to use the same authentication cookies.

The first site is an intranet site using Windows authentication. This site has one simple Action that checks to see if the user was authenticated, if the user has been, it creates a FormsAuthentication cookie that it adds to the response. This cookie is created for a generic user that I determine from the User’s AD groups. The response then redirects the user to a second site that uses Forms Authentication.

When I run this on my local machine, everything works as described above. When I deploy this to our local web server, it doesn’t. I’ve tested to see if the user’s group is correctly determined and that it creates a valid user for the cookie, and I have verified that this is correct on the web server.

Here is how I’m doing all of the above:

First, I made both sites use the same same Machine Key for encryption and decryption.

When I create the cookie in Site1, I ensure that it has the same name and Domain as the cookies created on Site2.

     var cookie = FormsAuthentication.GetAuthCookie(userName, false);
     cookie.Domain = FormsAuthentication.CookieDomain; //This is the Domain of my 2nd site as they are different

     HttpContext.Response.Cookies.Add(cookie); //Add my cookie to the response
     HttpContext.Response.RedirectPermanent(urlForSite2);

Again, when I run this on my local machine it works without a problem. But when deployed, it’s either not passing the cookie in the request, or the response is ignoring it, but I’m not sure how to verify either of these cases.

Feel free to ask any question regarding more details as to how I’m doing this if it will help in getting an answer I need.

  • 1 1 Answer
  • 2 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-24T17:45:37+00:00Added an answer on May 24, 2026 at 5:45 pm

    Cross domain cookies are not allowed. If you have two separate domains; one cannot access the others cookies. Two separate virtual directories/applications will work when using the same machine key. http://blogs.technet.com/b/sandy9182/archive/2007/05/07/sharing-forms-cookie-between-asp-net-web-application.aspx

    If you want to share login cookies between sub-domains you need to edit the Domain property of the login cookie to the 2nd level domain “abc.com” so that “www.abc.com” and “ww2.abc.com” will have access to the cookie. http://forums.asp.net/t/1533660.aspx

    String usrName = User.Identity.Name.ToString();
    HttpCookie authCookie = Security.FormsAuthentication.GetAuthCookie(usrName, false);
    authCookie.Domain = "abc.com";
    Response.AppendCookie(authCookie);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two fields on an MVC3 form that must represent the same value.
I have two domains: mydomain.com and mydomain.fr They both correspond to the same IP
I currently have two unrelated MVC3 projects hosted online. One works fine, the other
I have a asp.net MVC3 Application with two users Admin and General.Cookies is saved
I have an MVC3 C#.NET web app. I have two properties that are doubles
I am using MVC3, EF Model first. I have a form with two DropDownList
I have two applications written in Java that communicate with each other using XML
I had created a webpage using asp.net mvc3 razor. I have two master pages
I have two websites, A and B , very similar in configuration and both
I have two IIS websites, namely accounts.example.com that was created in Visual Studio 2010

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.