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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T06:22:42+00:00 2026-05-27T06:22:42+00:00

I have a web-service, ‘AHandyWebService’ implemented within a .aspx ( not within the .aspx.cs).

  • 0

I have a web-service, ‘AHandyWebService’ implemented within a .aspx (not within the .aspx.cs).

I’m trying to set a cookie on the client when the web-service is called.

I’m not sure whether this is just intrinsically impossible or whether it’s something to do with the way I’ve done it.

Because the method implementing the w-s is static I’ve had to implement a local instance of ‘page’ which I’m not sure is quite as it should be.

Method looks like this :

[WebMethod]
[ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json, XmlSerializeString = false)]
public static SomeObj AHandyWebService()
{
    SomeObj mySomeObj;
    try
    {
        mySomeObj = getSomeObj();
        System.Web.UI.Page p = new Page();
        HttpCookie appCookie = new HttpCookie("FOOAPP");
        appCookie.Value = String.Format("Written: {0:yyyy-MM-dd}", System.DateTime.Now.ToUniversalTime());
        appCookie.Expires = System.DateTime.Now.ToUniversalTime().AddMinutes(1);
        appCookie.Path = "/FOO";
        p.Response.Cookies.Add(appCookie);

    }
    catch (Exception ex)
    {
        throw;
    }

    return mySomeObj;

}

By the way there are no cross-domain issues here – the w-s is provided from the same domain as the w-s consuming page was served from.

Would welcome suggestions/comments.

  • 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-27T06:22:43+00:00Added an answer on May 27, 2026 at 6:22 am

    OK this is a bit embarrassing. After a lot of trying different things I discovered the method supporting the w-s was not in fact the method I thought it was ! … hence no cookie served !

    Meanwhile in other news I came across this StackOverflow question which provided what seemed to me a more sane method of getting around accessing the Response object from a static method and so I have implemented that and it now works as it should.

    In case it’s of some use here’s a copy of the now working method:

    [WebMethod]
    [ScriptMethod(UseHttpGet = true, ResponseFormat = ResponseFormat.Json, XmlSerializeString = false)]
    public static SomeObj AHandyWebService()
    {
    
        SomeObj mySomeObj;
    
        try
        {
            mySomeObj = getSomeObj();
            HttpCookie appCookie = new HttpCookie("FOOAPP");
            appCookie.Value = String.Format("Written: {0:yyyy-MM-dd}", System.DateTime.Now.ToUniversalTime());
            appCookie.Expires = System.DateTime.Now.ToUniversalTime().AddMinutes(1);
            appCookie.Path = HttpContext.Current.Request.ApplicationPath;
            HttpContext.Current.Response.Cookies.Add(appCookie);
        }
        catch (Exception ex)
        {
            throw;
        }
        return mySomeObj;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a web service client using axis. It's using document/literal style and supposed
i have a web service project called (WS_Service) i have a html page thats
I have implemented web service using rails server. The server uses rails default authentication
I have a Web service set up using Zend_Soap, and some public methods in
I have a web service with a client written in Java. The service works
I have a web service and some methods and I do NOT want to
I have a web service I'm trying to hit, URL looks like this: http://servername/webapp/ws/invoices/{invoiceid}
I have a web service that runs perfectly when i reference it from within
I have a web service I am trying to unit test. In the service
I have web service, which use integrated security in IIS. Now, I want to

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.