Re: session variable and asynchrous call



Bryan,

I am quite familiar with caching, but I'm not sure this will work. The
data I'm retrieving is specific to each user. This is why I'm choosing
cookies as my data store. I can temporarily (until the next
request/response cycle) place these somewhere else, as long as I can
get back to the values in the next cycle. In order to scope these to
the current user, session variables seemed like the logical answer, but
this doesn't appear to work under these conditions. I'm willing to
entertain other solutions as well.

Again the heart of the problem is that the data retrieval may take a
while to complete. I am requesting this data asynchronously so the
user is not impacted. However the callback may not be invoked until
after the response has been streamed to the user. Is there some place
I can store the data that will be in the user's scope on the next
request/response cycle?


Bryan Phillips wrote:
You should look into caching your data in the ASP.Net Cache. When you
add the item to cache, you can specify a duration and a method to call
when the cached value expires. Then you can reload the data in the
background without affecting the users.

Bryan Phillips
MCSD, MCDBA, MCSE
Blog: http://bphillips76.spaces.live.com




"carrolky@xxxxxxxxx" <carrolky@xxxxxxxxx> wrote in message
news:1161902882.460605.218100@xxxxxxxxxxxxxxxxxxxxxxxxxxx:

Here's my scenario. Please advise me if you can.

I have an ASP.NET web application on a corporate intranet which
retrieves some user information it uses from a webservice. The data
does not change often, but when it does, my site needs the updated
information. The connection to the database is slow and occasionally
unreliable. To avoid problems, we are storing the needed information
in cookies that do not expire for over 10 years. We use the cookie
values in the absence of "better information". Periodically we'd like
to update the cookie values. Our approach is to include an additional
cookie that expires weekly. When a user returns to our site, we check
for the presence of this cookie, if it is not present (new user or
expired cookie) we need to query the webservice. This can take long to
return (or may timeout), and we cannot make our users wait. BTW, all
of this processing occurs in a PreRequestHandlerExecute event handler
method of an HTTP module.

In order to refresh the data without waiting, I would like to call the
web service asynchronously. I have written the code to use an
HttpWebRequest object and call the BeginGetRequestStream method. I
have a callback function that parses the responsestream and extracts
the data I need. I need to put this data into cookies. I can wait
until the next request/response cycle.

My question is this: Since the callback function may not be invoked
until after the response has been streamed to the client, where can I
put the information I've retrieved? I've tried adding a reference to
the current session to my state object. I then store the information
in Session variables using the state object. This works while the cal
back function is executing (the values exist in session variables).
The values are gone when the next request cycle is processed.

Am I doing something wrong? Is this not a viable approach? If not,
where can I store this data in the case that the response has already
been streamed to the client?

Again, any advice would be appreciated.

.



Relevant Pages

  • FOLLOW UP : Forms Authentication Randomly Times Out (Windows 2003)
    ... a server config issue rather than code problem. ... The persist cookie is working as I can see it ... Apparently their Forms Authenicated session has ... expired however & there seems to be no pattern as to when it expires. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • FOLLOW UP : Forms Authentication Randomly Times Out (Windows 2003)
    ... >a server config issue rather than code problem. ... >the auth cookie expires. ... The persist cookie is working ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: session variable and asynchrous call
    ... When you add the item to cache, you can specify a duration and a method to call when the cached value expires. ... to update the cookie values. ... in Session variables using the state object. ...
    (microsoft.public.dotnet.framework)
  • RE: Conditional execution of Signout
    ... Have you tried to set the cookie's Expires to DateTime.MinValue? ... make it a session cookie. ... It will expires after you close the browser. ... defaultpage which has a signout link. ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: COOKIE EXPIRATION TIME
    ... The definition you gave is correct, you do specify a time that the cookie ... will expires on the client. ... The code I gave you comes directly from the MSDN help on the Expires ... - sounds like an absolute value... ...
    (microsoft.public.dotnet.framework.aspnet)

Loading