I have a situation where I think I'm calling a method too quickly, but
I'm not sure a) how to prove that theory and b) slow it down if I'm
right. Here's the code:
CODEFILE.ASPX.C S
public void updateCookie(st ring cookieName, string cookiePairName,
string cookiePairValue ) {
if (Request.Cookie s[cookieName] != null) {
string currentCookie = Request.Cookies[cookieName].Value;
currentCookie += "&" + cookiePairName + "=" + cookiePairValue ;
Response.Cookie s[cookieName].Value = currentCookie;
}
else
{
Response.Cookie s[cookieName][cookiePairName] = cookiePairValue ;
}
Response.Cookie s[cookieName].Expires = DateTime.Now.Ad dDays(30);
}
SETCOOKIE1.ASPX
....
<%
updateCookie("C ommunities","Lo ggedIn","true") ;
updateCookie("C ommunities","me mber_id","120") ;
%>
....
SETCOOKIE2.ASPX
....
<%
updateCookie("C ommunities","ba nner","1");
updateCookie("C ommunities","em ailaddress","ke ***@mydomain.co m")
%>
....
VIEWCOOKIE.ASPX
....
Response.Write( Request.Cookies["Communitie s"].Value);
....
The issue is this:
- initially I delete all cookies from I.E. and view 'viewcookie.asp x'
to confirm that no cookie value is displayed.
- Next I view 'setcookie1.asp x', then go back to 'viewcookie.asp x',
refresh and I see something like 'LoggedIn=true& member_id=120', as I'd
expect.
- I then view 'setcookie2.asp x', go back to 'viewcookie.asp x' and
refresh...
this time I see
'LoggedIn=true& member_id=120&e mailaddress=ke* **@mydomain.com ', whereas
I would expect to see '&banner=1' before '&emailaddress. ..', i.e. 4
name-value pairs set by the two aspx files, rather than just 3 pairs
if I comment out the 'updateCookie' lines one at a time in
setcookie2.aspx , they both work individually, but when they are both
uncommented, only one of the two calls to updateCookie actually work.
the same is true if I run setcookie2.aspx before I run
setcookie1.aspx .. i.e. both values from setcookie2.aspx are in the
cookie, but only one of those from setcookie1.aspx gets entered.
also, if I go back to the setcookie file where both entries were added
and run it again while the cookie exists, only one of the two
previously working entries is appended
Am I calling the method too quickly? can I slow it down? Is there a
better way to do the cookie part that won't cause this??
any help would be very appreciated (let me know if my explaination is
too irratic <g>) 2 1375
I've discovered that what's happening isn't that the method is being
used to quickly, but rather the creation of the new cookie isn't being
commited between each call to the method.
In my testing I found that I can update the cookie in setCookie.aspx,
and then if I try to access that cookie in the same page, using
Request.Cookies , it will show the old, un-updated value.
This means that when I call the method for the second time, the cookie
value I am reading and appending to is the old one, not the new one.
The only time I see the new value of the cookie is when I either reload
the page, or go to another page, such as viewcookie.aspx .
Any clues why the cookies is not 'instantly' being written??
Kevin
Kevin Blount wrote:
I have a situation where I think I'm calling a method too quickly, but
I'm not sure a) how to prove that theory and b) slow it down if I'm
right. Here's the code:
CODEFILE.ASPX.C S
public void updateCookie(st ring cookieName, string cookiePairName,
string cookiePairValue ) {
if (Request.Cookie s[cookieName] != null) {
string currentCookie = Request.Cookies[cookieName].Value;
currentCookie += "&" + cookiePairName + "=" + cookiePairValue ;
Response.Cookie s[cookieName].Value = currentCookie;
}
else
{
Response.Cookie s[cookieName][cookiePairName] = cookiePairValue ;
}
Response.Cookie s[cookieName].Expires = DateTime.Now.Ad dDays(30);
}
SETCOOKIE1.ASPX
...
<%
updateCookie("C ommunities","Lo ggedIn","true") ;
updateCookie("C ommunities","me mber_id","120") ;
%>
...
SETCOOKIE2.ASPX
...
<%
updateCookie("C ommunities","ba nner","1");
updateCookie("C ommunities","em ailaddress","ke ***@mydomain.co m")
%>
...
VIEWCOOKIE.ASPX
...
Response.Write( Request.Cookies["Communitie s"].Value);
...
The issue is this:
- initially I delete all cookies from I.E. and view 'viewcookie.asp x'
to confirm that no cookie value is displayed.
- Next I view 'setcookie1.asp x', then go back to 'viewcookie.asp x',
refresh and I see something like 'LoggedIn=true& member_id=120', as I'd
expect.
- I then view 'setcookie2.asp x', go back to 'viewcookie.asp x' and
refresh...
this time I see
'LoggedIn=true& member_id=120&e mailaddress=ke* **@mydomain.com ', whereas
I would expect to see '&banner=1' before '&emailaddress. ..', i.e. 4
name-value pairs set by the two aspx files, rather than just 3 pairs
if I comment out the 'updateCookie' lines one at a time in
setcookie2.aspx , they both work individually, but when they are both
uncommented, only one of the two calls to updateCookie actually work.
the same is true if I run setcookie2.aspx before I run
setcookie1.aspx .. i.e. both values from setcookie2.aspx are in the
cookie, but only one of those from setcookie1.aspx gets entered.
also, if I go back to the setcookie file where both entries were added
and run it again while the cookie exists, only one of the two
previously working entries is appended
Am I calling the method too quickly? can I slow it down? Is there a
better way to do the cookie part that won't cause this??
any help would be very appreciated (let me know if my explaination is
too irratic <g>)
Hi Kevin,
Try buffering all changes to cookies until immediately before the request is completed.
using System.Collecti ons.Generic;
/// <summary><see cref="Dictionar y" /of string keys and values for buffering cookies until
the <see cref="Page" /is rendered, at which time the buffered cookies are written to the
<see cref="Response" /in the <see cref="Page.PreR ender" /event.</summary>
private readonly void Dictionary<stri ng, Dictionary<stri ng, string>>
cookieBuffer = new Dictionary<stri ng, Dictionary<stri ng, string>>();
--
Dave Sexton
"Kevin Blount" <ke**********@g mail.comwrote in message news:11******** **************@ i42g2000cwa.goo glegroups.com.. .
I've discovered that what's happening isn't that the method is being
used to quickly, but rather the creation of the new cookie isn't being
commited between each call to the method.
In my testing I found that I can update the cookie in setCookie.aspx,
and then if I try to access that cookie in the same page, using
Request.Cookies , it will show the old, un-updated value.
This means that when I call the method for the second time, the cookie
value I am reading and appending to is the old one, not the new one.
The only time I see the new value of the cookie is when I either reload
the page, or go to another page, such as viewcookie.aspx .
Any clues why the cookies is not 'instantly' being written??
Kevin
Kevin Blount wrote:
>I have a situation where I think I'm calling a method too quickly, but I'm not sure a) how to prove that theory and b) slow it down if I'm right. Here's the code:
CODEFILE.ASPX. CS public void updateCookie(st ring cookieName, string cookiePairName, string cookiePairValue ) { if (Request.Cookie s[cookieName] != null) { string currentCookie = Request.Cookies[cookieName].Value; currentCooki e += "&" + cookiePairName + "=" + cookiePairValue ; Response.Cooki es[cookieName].Value = currentCookie; } else { Response.Cooki es[cookieName][cookiePairName] = cookiePairValue ; } Response.Cooki es[cookieName].Expires = DateTime.Now.Ad dDays(30); }
SETCOOKIE1.ASP X ... <% updateCookie(" Communities","L oggedIn","true" ); updateCookie(" Communities","m ember_id","120" ); %> ...
SETCOOKIE2.ASP X ... <% updateCookie(" Communities","b anner","1"); updateCookie(" Communities","e mailaddress","k e***@mydomain.c om") %> ...
VIEWCOOKIE.ASP X ... Response.Write (Request.Cookie s["Communitie s"].Value); ...
The issue is this: - initially I delete all cookies from I.E. and view 'viewcookie.asp x' to confirm that no cookie value is displayed. - Next I view 'setcookie1.asp x', then go back to 'viewcookie.asp x', refresh and I see something like 'LoggedIn=true& member_id=120', as I'd expect. - I then view 'setcookie2.asp x', go back to 'viewcookie.asp x' and refresh...
this time I see 'LoggedIn=true &member_id=120& emailaddress=ke ***@mydomain.co m', whereas I would expect to see '&banner=1' before '&emailaddress. ..', i.e. 4 name-value pairs set by the two aspx files, rather than just 3 pairs
if I comment out the 'updateCookie' lines one at a time in setcookie2.asp x, they both work individually, but when they are both uncommented, only one of the two calls to updateCookie actually work.
the same is true if I run setcookie2.aspx before I run setcookie1.asp x.. i.e. both values from setcookie2.aspx are in the cookie, but only one of those from setcookie1.aspx gets entered.
also, if I go back to the setcookie file where both entries were added and run it again while the cookie exists, only one of the two previously working entries is appended
Am I calling the method too quickly? can I slow it down? Is there a better way to do the cookie part that won't cause this??
any help would be very appreciated (let me know if my explaination is too irratic <g>)
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: lkrubner |
last post by:
I killed last night and a good chunk of today trying to figure out this
one particular attempt to get a class and initialize it. My code is
using a class method called getObject to include() a file and then
initialize the class in that file (one class per file, each file has
the same name as the class). This code has been working fine for 8...
|
by: Jazper |
last post by:
hi
i have this problem. i made a class deverted by CRootItem with
implementation of IDisposable-Interface. i made a test-funktion to test my
Dispose-Method.... but when set a breakpoint in my Dispose-Method and call
the GC nothing happend!!! my Disposemethod has never been called!! so the GC
dont call my Dispose-Method although I...
|
by: moondaddy |
last post by:
I have a website where cataloge pages are populated by calling a stored
procedure on sql server. I use the sql data adapter's fill method to call
this stored procedure and fill the dataset. about 6 to 15 times a day the
server hangs and times out when this fill method is called. The SP is
simple and uses very little resources (as tested...
|
by: JohnR |
last post by:
From reading the documentation, this should be a relatively easy thing. I
have an arraylist of custom class instances which I want to search with
an"indexof" where I'm passing an instance if the class where only the
"searched" property has a value. I expected to get the index into the
arraylist where I could then get the entire class...
|
by: Vincent |
last post by:
I have a hierarchical flex grid on an Access form and in the MouseMove
routine for the flex grid I am changing the color of the cells as the
mouse is moved over the cell. If I move the mouse slowly, all of the
cells change color as I expect. If I move the mouse quickly, some of
the cells are skipped--the MouseMove event is simply not being...
| |
by: Allan Ebdrup |
last post by:
I'm writing some code where I have have a class that implements 4 methods
(class A)
I only want to call these methods from the base class if they have been
overridden in a sub class (Class B) I guess I could have some properties
that specify wether to call the methods, but I would like to call them
automatically when they are overridden, how...
|
by: Agustin Villena |
last post by:
Hi!
is there anyway to show the class of a method in an exception's
traceback?
For example, the next code
class Some(object):
def foo(self,x):
raise Exception(x)
|
by: Anders Borum |
last post by:
Hi!
While implementing a property manager (that supports key / value pairs), I
was wondering how to constrain T to a struct or string type. Basically, I
guess what I'm looking for is the common denominator for structs and strings
and while looking through the SDK I only noticed the IEquatable<T>
interface.
So I implemented the class with...
|
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...
|
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. ...
|
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...
| |
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...
|
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...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
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...
| |