Pasing a reference to my page's Response.Cookies collection

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default Pasing a reference to my page's Response.Cookies collection

    I would like to have my ASPX page call a function intended to make
    changes the the current Page.Response.Cookies. I had thought that to
    allow the function to modify the Cookies, I would have top pass the
    collection by REFERENCE. But I am getting

    "A property or
    indexer may not be passed as an out or ref parameter"

    Here is a simple example of what I am trying to do...

    public class MyPage: System.Web.UI.Page
    {
    MySetCookieButton_Click(object sender, ....)
    {
    CookieFuncs.SetCookies(ref this.Page.Response.Cookies)
    }
    }

    public class CookieFuncs
    {
    public static void SetCookies(ref System.Web.HttpCookieCollection
    cookies)
    {
    cookies.Value = etc.......
    }

    }
    Scott Guest

  2. Similar Questions and Discussions

    1. How to get pdf file page's information
      If one of the PDF file pages is rotated by 90 angles and becomes horizontal, It is still vertical when I print it out to be an image. So I want to...
    2. Change a Page's template?
      I have a site that has two templates: a single column template and a two column template. I would like to know if it is possible to take an existing...
    3. Can I get the current page's URL?
      I was wondering if there is a way to get the current page's url string via Flash. I want to be sure my Flash file is only played on a particular...
    4. Response.Cookies(x).Domain ???
      Hi, I am looking for a way to delete (expire) all the cookies that we've ever written to the user's machine. I have found several scripts,...
    5. how to process items in response.form collection dynamically?
      HI. in asp.net app, I have an xmlDocument that I transform to the client html. Using xsl I create a few textboxes to capture user input. Each of...
  3. #2

    Default Re: Pasing a reference to my page's Response.Cookies collection

    If you take a look at the class reference, you will find that the Cookies
    property of the HttpResponse class is a getter. As indicated by your error
    message, you can't pass this by reference. However, make no mistake about
    it - you are not doing a deep copy here. If you remove the ref, then you are
    no longer trying to pass a reference to the property, but will start passing
    the return value of the property - a reference to the cookies collection
    that you want. Check out the SDK for a review of which values are passed by
    value and which are passed by reference.

    --
    Chris Jackson
    Software Engineer
    Microsoft MVP - Windows XP
    Windows XP Associate Expert
    --
    "Scott" <hillscottc@hotmail.com> wrote in message
    news:6ac5e33c.0308121110.544b8d9e@posting.google.c om...
    > I would like to have my ASPX page call a function intended to make
    > changes the the current Page.Response.Cookies. I had thought that to
    > allow the function to modify the Cookies, I would have top pass the
    > collection by REFERENCE. But I am getting
    >
    > "A property or
    > indexer may not be passed as an out or ref parameter"
    >
    > Here is a simple example of what I am trying to do...
    >
    > public class MyPage: System.Web.UI.Page
    > {
    > MySetCookieButton_Click(object sender, ....)
    > {
    > CookieFuncs.SetCookies(ref this.Page.Response.Cookies)
    > }
    > }
    >
    > public class CookieFuncs
    > {
    > public static void SetCookies(ref System.Web.HttpCookieCollection
    > cookies)
    > {
    > cookies.Value = etc.......
    > }
    >
    > }

    Chris Jackson Guest

  4. #3

    Default Re: Pasing a reference to my page's Response.Cookies collection

    "Scott" <hillscottc@hotmail.com> wrote in message
    news:6ac5e33c.0308121110.544b8d9e@posting.google.c om...
    > I would like to have my ASPX page call a function intended to make
    > changes the the current Page.Response.Cookies. I had thought that to
    > allow the function to modify the Cookies, I would have top pass the
    > collection by REFERENCE. But I am getting
    Just pass Response.Cookies. Objects are already references.
    --
    John Saunders
    Internet Engineer
    [email]john.saunders@surfcontrol.com[/email]



    John Saunders Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139