473,804 Members | 3,750 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

I would like to have my ASPX page call a function intended to make
changes the the current Page.Response.C ookies. 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.P age
{
MySetCookieButt on_Click(object sender, ....)
{
CookieFuncs.Set Cookies(ref this.Page.Respo nse.Cookies)
}
}

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

}
Nov 17 '05 #1
2 2487
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********@hot mail.com> wrote in message
news:6a******** *************** ***@posting.goo gle.com...
I would like to have my ASPX page call a function intended to make
changes the the current Page.Response.C ookies. 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.P age
{
MySetCookieButt on_Click(object sender, ....)
{
CookieFuncs.Set Cookies(ref this.Page.Respo nse.Cookies)
}
}

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

}

Nov 17 '05 #2
"Scott" <hi********@hot mail.com> wrote in message
news:6a******** *************** ***@posting.goo gle.com...
I would like to have my ASPX page call a function intended to make
changes the the current Page.Response.C ookies. 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.Cookie s. Objects are already references.
--
John Saunders
Internet Engineer
jo***********@s urfcontrol.com

Nov 17 '05 #3

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

Similar topics

18
2479
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 need: A system whereby the user only has to register ONCE and he will have automatic entry to ANY page without havinto to RE-LOGIN even if he comes in
6
3095
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. However, I ran into a scenario that I'm baffled by. I have a website which requires a user to login. This is nothing new and I was able to successfully log in. For our case, let's say the URL to the login page is http://login.html
1
1857
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. What do I need to do to have the cookies sent along with the request Below is the code snippet from the function I an using I am using to achieve the above. EVerything works except that I do not see any cookies in request object for the ASPX page...
1
11457
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 cmdAddCookie.Click Dim strCookieName As String Dim objRandom As New Random() strCookieName = "MyCookie" & objRandom.Next(Integer.MaxValue).ToString
1
1894
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 on the client. The second cookie contains its original value on postback, not the new value. Can someone tell me why I can't update the second cookie? Here is a code sample.
2
1608
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 one part to communicate via a cookie. (Please dont ask me to go into why, I don't have time). In my ASP page, I created a cookie and put a value in it: Response.Cookies("MyCookieName") = "OriginalValue" Response.Cookies("MyCookieName").Expires...
8
2203
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 same time, in the middle of my data entry , it is brining someelse data on my screen. I look everywhere i could not find the solution. Please help me Radx
6
5127
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 a button EDIT ,which when user clicks directs him to another page (done.asp). Now the problem is that from this page (done.asp) if he clicks on the back button on the toolbar then edit.asp opens.But I don't want it to open It should show page...
1
2028
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 HttpCookie("affidcookie", CInt (Request.QueryString("affid"))) affCookie.Expires = Now().AddDays(30) Response.Cookies.Add(affCookie) Session("affID") = CInt(Request.QueryString("affid"))
0
9706
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10583
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10337
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9160
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.