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

  • Home
  • SEARCH
  • 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
  • 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-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 applications written in Java that communicate with each other using XML
I have two insert statements, almost exactly the same, which run in two different
I have two nested repeaters in my *.aspx page. <asp:Repeater runat=server id=rptMain> <ItemTemplate> <h1><%#DataBinder.Eval(Container.DataItem,
I need to develop a web application, i have two choices mvc3 straight forward
I have a function in my MVC3 application that presents a user with a
I hope that title is clear enough. I have 2 projects, MyProject.Website (ASP.NET MVC3
I have two canvas's in a Grid, full scene images that I want to
I have two classes, a server and some clients. The server class make a
I'm working on a single sign-on solution for two ASP.NET MVC3 websites. The sites
BACKGROUND: I'm using two MVC3 websites for mixed mode authentication. I'm authenticating a person

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.