Re: session variable and asynchrous call



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

  • Re: session wont timeout
    ... Maybe this is a session cookie issue? ... client browser there is this one: WSS_KeepSessionAuthenticated Expires: At ... If I kill the session cookie using IE Developer Toolbar, ... possible and IIS would throw another challenge. ...
    (microsoft.public.sharepoint.windowsservices)
  • Re: Role Providers Cache
    ... do our own cache using the cache management API. ... farm environment with out of process session state. ... Auth Manager Role Provider or use the SQL Role provider (moving the roles ... So my main concern was on the cache feature and the cookie was worried we ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Role Providers Cache
    ... If you have sticky session support, then you can use in process session ... do our own cache using the cache management API. ... Auth Manager Role Provider or use the SQL Role provider (moving the ... So my main concern was on the cache feature and the cookie was worried ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Authorization question, w/ "Windows" authentication mode
    ... session is not available in Post/AuthenticateRequest - i would use the cache or a cookie ... if cookie i would use the userData field of the FormsAuth ticket - this gives you encryption and integrity protection + renewal for free ... it appears the Session object doesnt yet exist "Session_Start" is ...
    (microsoft.public.dotnet.framework.aspnet.security)
  • Re: Identify User After Session Ends
    ... > session is timeout, we need to send a mail to him with his editing datas. ... > store in cookie to idenitfy him. ... > that use the Application Cache to store the user's data. ... > Expire Time and add EXpire event handler for cache object in asp.net. ...
    (microsoft.public.dotnet.framework.aspnet)

Loading