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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T18:47:33+00:00 2026-06-02T18:47:33+00:00

I have an ordering website that needs to make a set up request on

  • 0

I have an ordering website that needs to make a set up request on a supplier site.
For this i am using a WebHanlder (ashx file) to read the setup request in cXML using the HttpContext object which is working fine.

One of the requirements is that we send back a Cookie called “Buyer Cookie” along with a cXML 200 OK response.

The problem I am having is when I create a cookie in the context.Response it is not recieved in the ordering site when I do the response.Output.Write().

I have tried using response.Flush() after the write and this is still not working

How can I send a cookie back to the calling site?

Here is my code:

Ordering site

Stream stream = null;
byte[] bytes = Encoding.ASCII.GetBytes(File.ReadAllText(@"D:\Prototypes\HTTPPost\cXMLFiles\PunchOutSetupRequest.xml"));
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create("http://localhost:45454/PunchOutRequest.ashx");

webRequest.ContentType = "application/x-www-form-urlencoded";
webRequest.Method = "POST";
webRequest.ContentLength = bytes.Length;

try
{
    stream = webRequest.GetRequestStream();
    stream.Write(bytes, 0, bytes.Length);
}
catch (Exception)
{
    throw;
}
finally
{
    if (stream != null)
        stream.Close();
}

HttpWebResponse response = (HttpWebResponse)webRequest.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader responseReader = new StreamReader(responseStream);

string r = responseReader.ReadToEnd();
var buy = webRequest.CookieContainer;
var buyer = response.Cookies["BuyerCookie"]; // This is always null

Supplier Site

var request = context.Request;
StreamReader reader = new StreamReader(request.InputStream);

string text = reader.ReadToEnd();

POSetup setup = new POSetup();

if (setup.IsSetupRequestValid(text))
{
    HttpCookie cookie = new HttpCookie("BuyerCookie", "100");

    context.Response.Cookies.Add(cookie);
    context.Response.Output.Write(setup.GetOKResponse());
}
  • 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-06-02T18:47:34+00:00Added an answer on June 2, 2026 at 6:47 pm

    Try adding this line:

    webRequest.CookieContainer = new CookieContainer();
    

    right after

    webRequest.ContentLength = bytes.Length;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have this API to our ordering system in our Call-Center, that our online-ordering
I searched for an implementation of std::map runtime ordering and have found this solution:
I have an architectural question on handling message ordering. For purposes of this question,
Have a SomeLib.pro file that contains: CONFIG += debug TEMPLATE = lib TARGET =
I have some pages on a website and I have to create an ordering
I received a somewhat unusual request (imo) for a transactional web site. I have
If I have multiple dicts that have the same set of keys (and nearly
I have deployed a website using Visual Studio 2010 on IIS6. I used one
We have an ordering system that is currently quite hard coded. We would like
To index my website, I have a Ruby script that in turn generates a

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.