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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:54:02+00:00 2026-05-23T13:54:02+00:00

I feel like this is a rather simple question, but I can’t seem to

  • 0

I feel like this is a rather simple question, but I can’t seem to figure it out. I understand how to create a webRequest with HttpWebRequest, send it to the server, and handle the response.

In Microsoft’s ASP.NET examples like:

protected void Page_Load(object sender, EventArgs e)
{
    StringBuilder sb = new StringBuilder();
    // Get cookie from the current request.
    HttpCookie cookie = Request.Cookies.Get("DateCookieExample");

    // Check if cookie exists in the current request.
    if (cookie == null)
    {
        sb.Append("Cookie was not received from the client. ");
        sb.Append("Creating cookie to add to the response. <br/>");
        // Create cookie.
        cookie = new HttpCookie("DateCookieExample");
        // Set value of cookie to current date time.
        cookie.Value = DateTime.Now.ToString();
        // Set cookie to expire in 10 minutes.
        cookie.Expires = DateTime.Now.AddMinutes(10d);
        // Insert the cookie in the current HttpResponse.
        Response.Cookies.Add(cookie);
    }
    else
    {
        sb.Append("Cookie retrieved from client. <br/>");
        sb.Append("Cookie Name: " + cookie.Name + "<br/>");
        sb.Append("Cookie Value: " + cookie.Value + "<br/>");
        sb.Append("Cookie Expiration Date: " + 
            cookie.Expires.ToString() + "<br/>");
    }
    Label1.Text = sb.ToString();
}

(From http://msdn.microsoft.com/en-us/library/system.web.httpcookie.aspx)

Request and Response are already declared and just exist.

I am developing a web service instead of a full website. Is this why I do not see Request and Response already defined?

I do not understand why I am having so much trouble with this. I asked a similar question here: How can I use ASP.NET to check if cookies are enabled without having a web page? so either I am missing something completely obvious, or the problem I am trying to solve is very nonstandard.

I thank you for any help.

EDIT:

I’m trying to do something like this:

    [WebMethod]
    public bool CookiesEnabledOnClient()
    {
        bool retVal = true;
        var request = (HttpWebRequest)WebRequest.Create("http://www.dealerbuilt.com");
        request.Method = "Head";
        var response = (HttpWebResponse)request.GetResponse();
        HttpCookie Httpcookie = new HttpCookie("CookieAccess", "true");

        response.Cookies.Add(Httpcookie);      
        //If statement checking if cookie exists.

        return retVal;
    }

But Cookies.Add will not accept the Httpcookie and when I use a normal cookie it isn’t added.

  • 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-23T13:54:02+00:00Added an answer on May 23, 2026 at 1:54 pm

    Remember, in ASP.Net the Page_Load() method (and any other method on a web page) is a member of a class, and this class inherits from another class. The properties list of that base class includes both Request and Response.

    As for the latter part of your question, look for the Context variable. It is already defined for your web service in a manner similar to how Request and Response are available in a web page, and it will give you access to those properties, including any cookies in the request.

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

Sidebar

Related Questions

I feel like this is a dumb question and I'm missing something, but I
I feel like I should know this, but I haven't been able to figure
I have a rather simple question for you.. I feel like I should have
I feel like this is a stupid question because it seems like common sense
I'm sorry, but this is beginning to feel like kicking myself in the head.
This is very simple, but I'm being rather stupid about it. I have a
I feel like a fool, but here goes: public interface IHasErrorController{ ErrorController ErrorController {
I feel like I'm re-inventing the wheel here, but I need to find a
I feel like developers talk about memory leaks but when you ask them what
This is probably something simple but I'm scratching my head over easing with the

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.