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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:53:47+00:00 2026-05-30T18:53:47+00:00

I have two sites which I use the same cookie for login which works

  • 0

I have two sites which I use the same cookie for login which works fine.

The issues that I’m having is that both sites are completely different looking in design and I would like one of the sites to handle the login functionality and the other simply to do a post of the username / password to the other and create the cookie in the backend.

I have this functioning but the issue is how do I notify the other site that the login has been successful or has failed without actually going to the other site to complete the login process?

I have created something like this which works fine but it is the question of how I should handled the post on the other website and what I should return as a response that puzzles me.

Any ideas or alternative solutions would a great help to me!

[HttpPost]
public ActionResult FormPost(LogOnModel model)
{
WebRequest request = WebRequest.Create(strServer);

            // Set the Method property of the request to POST.
            request.Method = "POST";
            // Create POST data and convert it to a byte array.
            byte[] byteArray = Encoding.UTF8.GetBytes("password=" + model.Password);
            // Set the ContentType property of the WebRequest.
            request.ContentType = "application/x-www-form-urlencoded";
            // Set the ContentLength property of the WebRequest.
            request.ContentLength = byteArray.Length;
            // Get the request stream.
            Stream dataStream = request.GetRequestStream();
            // Write the data to the request stream.
            dataStream.Write(byteArray, 0, byteArray.Length);
            // Close the Stream object.
            dataStream.Close();

            // Get the response.
            WebResponse response = request.GetResponse();
            // Get the stream containing content returned by the server.
            dataStream = response.GetResponseStream();
            // Open the stream using a StreamReader for easy access.
            StreamReader reader = new StreamReader(dataStream);
            // Read the content.
            string responseFromServer = reader.ReadToEnd();
            // Clean up the streams.
            reader.Close();
            dataStream.Close();
            response.Close();

TempData["Response"] = responseFromServer;

return View();
  • 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-30T18:53:48+00:00Added an answer on May 30, 2026 at 6:53 pm

    You could capture the cookies that were sent by the authentication action and simply append them to the response so that the actual user that performed the request gets this cookie in his browser:

    [HttpPost]
    public ActionResult FormPost(LogOnModel model)
    {
        using (var client = new WebClient())
        {
            var data = new NameValueCollection
            {
                { "username", "foo" },
                { "password", "bar" },
            };
            var result = client.UploadValues("http://localhost:1631/account/logon", data);
            var cookie = client.ResponseHeaders[HttpResponseHeader.SetCookie];
            Response.AddHeader("Set-Cookie", cookie);
        }
        return View();
    }
    

    But using a common authentication service seems like a much better idea instead of doing screen scraping.

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

Sidebar

Related Questions

I have two different domains that both point to my homepage in the same
I have two sites that are app1 and app2. If a user requests a
I have two ASP.NET sites (they can not run in the same process) and
HELP! I just setup a virtual host for two sites that have a lot
I'm having some issues with a jQuery AJAX call. My code works fine when
In my company i have an application which should run at two different sites
I have a RelativeLayout with two children that are also both RelativeLayout s containing
I have two domains, domain1.com and domain2.com pointing at the same asp.net website which
I have two sites with different SITE_IDs, but I want to have only one
I am torn between to DRY and loose coupling :( I have two sites

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.