473,320 Members | 1,848 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

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.......
}

}
Nov 17 '05 #1
2 2459
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" <hi********@hotmail.com> wrote in message
news:6a**************************@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.......
}

}

Nov 17 '05 #2
"Scott" <hi********@hotmail.com> wrote in message
news:6a**************************@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
jo***********@surfcontrol.com

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: | last post by:
Please help. After a number of wrong turns and experiments I need advice on login management system to secure our web pages without inconveniencing our visitors or our internal staff. What I...
6
by: omyek | last post by:
I'm trying to mimic the browsing of a webpage using an HttpWebRequest. I've had a lot of luck with it so far, including logging into pages, posting form data, and even collecting and using cookies....
1
by: Bhupesh Saini | last post by:
I am trying to call a ASPX page using HttpWebRequest class and pass cookie information to it. My ASPX pages gets called just fine, however none of the request cookies are available to the ASPX page....
1
by: Alex Nitulescu | last post by:
I have the following very simple colde (while learning about cookies and session state): Private Sub cmdAddCookie_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
1
by: Ken Varn | last post by:
I have a page that uses two cookies. On postback, both cookies are updated and added back into the Page.Response.Cookies collection. For some reason, only the first cookie is actually updated...
2
by: Owen | last post by:
I have a web app that is a mixture of ASP and ASP.NET pages. Largely the only data passed between them is via the querystring, or by reading from a database. However there is a requirement for...
8
by: Radx | last post by:
Here in my web application, I have a data entry page with serval controls. Some of the controls have autopostback is set true. But the problem is when two or more people are entering data at the...
6
by: divya | last post by:
I have a page name edit.asp which should expire immediately .The user cannot open this page directly he has to provide a password for entering this page.thus when the user enters edit.asp , it has...
1
by: lacanela | last post by:
Since I want to use cookies on a site running asp.net 1.1. I have added the following code: If CInt(Request.QueryString("affid")) 0 Then Dim affcookie As HttpCookie affcookie = New...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.