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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T12:10:32+00:00 2026-05-30T12:10:32+00:00

i have just setup a proxy page to handle ajax requests but i cannot

  • 0

i have just setup a proxy page to handle ajax requests but i cannot get it working as cookies doesn’t get saved at all. My code is as follows:

public partial class JsonProxy : System.Web.UI.Page
{

private string username;
private string password;
private int idPlant;
private string mode;

protected void Page_Load(object sender, EventArgs e)
{
    try
    {
        username = !String.IsNullOrEmpty(HttpUtility.UrlDecode(Request.Form["username"])) ? HttpUtility.UrlDecode(Request.Form["username"].ToString()) : string.Empty;
        password = !String.IsNullOrEmpty(HttpUtility.UrlDecode(Request.Form["password"])) ? HttpUtility.UrlDecode(Request.Form["password"].ToString()) : string.Empty;
        idPlant = !String.IsNullOrEmpty(HttpUtility.UrlDecode(Request.Form["idPlant"])) ? int.Parse(HttpUtility.UrlDecode(Request.Form["idPlant"].ToString())) : 0;
        mode = !String.IsNullOrEmpty(HttpUtility.UrlDecode(Request.Form["mode"])) ? HttpUtility.UrlDecode(Request.Form["mode"].ToString()) : string.Empty;

        string response = "";
        HttpWebRequest wc;

        if (!String.IsNullOrEmpty(username) && !String.IsNullOrEmpty(password) && idPlant != 0 && !String.IsNullOrEmpty(mode))
        {
            //First do authentication
            wc= (HttpWebRequest)WebRequest.Create("http://10.255.255.10/Base/Authentication/Login/" + username + "/" + password + ".aspx");
            wc.Method = "GET";

            StreamReader  reader = new StreamReader(((HttpWebResponse)wc.GetResponse()).GetResponseStream());
            if (reader.ReadToEnd().Contains("true"))
            {
                //Then check that authentication succeded
                wc = (HttpWebRequest)WebRequest.Create("http://10.255.255.10/Base/Authentication/IsAuthenticated.aspx");
                wc.Method = "GET";

                reader = new StreamReader(((HttpWebResponse)wc.GetResponse()).GetResponseStream());

                string str = reader.ReadToEnd();
                if (str.Contains("true"))
                {
                    //Then make BP request
                    string methodName = "/Base/BusinessPlan/GetBPAlll/" + idPlant + ".aspx";
                    wc = (HttpWebRequest)WebRequest.Create("http://10.255.255.10" + methodName);
                    wc.Method = "GET";
                    reader = new StreamReader(((HttpWebResponse)wc.GetResponse()).GetResponseStream());
                    response = reader.ReadToEnd();
                }
            }

        }

        //Last: write response
        Response.ContentType = "application/json";
        Response.Write(response);
    }
    catch (WebException ex)
    {
        Response.Write("error");
    }
}

}

The login request should create some cookies in the client that are used in the next request (IsAuthenticated) and in the last one (the real request actually).
However IsAuthenticated return false just after i did the login correctly (i can see it return true as expected). It is like if i never logged in.
So the question is: how can i save cookies in proxy?
I am open to answers that take in consideration also HttpHandlers or other thechiques to do ajax proxying, not necessarily Aspx.
Note: if i make the same request series i can see cookies get created so it must be a matter about my aspx proxy

  • 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-30T12:10:33+00:00Added an answer on May 30, 2026 at 12:10 pm

    In this case cookies will not be saved in the client as this is server code that is making the request. The cookies will be sent as part of the response to your server but not back to the client.
    I think to get the behaviour you are hoping for you will need to get the cookie collection object from the initial response and copy that into the following two request objects.

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

Sidebar

Related Questions

I have an MVC 1.0 app just setup but it only shows the Index.aspx
I have just setup a wordpress forum and I find that all images are
We have just setup our hudson server to build .NET projects which seems to
HELP! I just setup a virtual host for two sites that have a lot
Just a basic html link question. I have an intranet setup, and I need
We have a terminal emulator (its more then just this, but for the question
I am planning to setup nginx as reverse proxy. I will have apache to
I have just set up cruise control.net on our build server, and I am
I have just set up ruby in Aptana studio and am getting the following
I'm fairly new to WebService developement and have just set up my own webservice

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.