differentiating between requests

P

Pietro

Hi, i would like to know if there is a way to differentiate between
requests, someting like a number that is unique only in the execution of
an individual request.

Thank you
Pietro
 
G

Guest

If you mean from different sessions/browsers/etc... sure
If you mean from the same user in the same session.. not really. You could
easily tie in an unique id (time perhaps).... but more to the point.. what is
the end goal you are after? What's the problem that lead you to this?
 
S

Stefan

No.

You can attach a unique identifier (e.g. a guid) to the request in the
Application_BeginRequest if you need it (sometimes useful for audit
purposes), e.g

HttpContext.Current.Items["ReqID"] = new GUID();
 
P

Pietro

Ex: My page has several controls, there is 2 users acessing this page, i
want the controls to share data in a commum place, like a static class,
but data from one user cannot be acesseable by other user, and i don´t
need the data avaliable between requests, it will last only in current
request.

Thanks
Pietro
 
J

John Horst

I think the code below should be:

HttpContext.Current.Items["ReqID"] = Guid.NewGuid().ToString();

John

-----Original Message-----
From: Stefan [mailto:[email protected]]
Posted At: Wednesday, August 31, 2005 12:39 PM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: differentiating between requests
Subject: Re: differentiating between requests


No.

You can attach a unique identifier (e.g. a guid) to the request in the
Application_BeginRequest if you need it (sometimes useful for audit
purposes), e.g

HttpContext.Current.Items["ReqID"] = new GUID();
 
S

Stefan

Sounds like you want your state to be stored in
HttpContext.Current.Items
(Each of your users has a different context and the lifecycle of
Context.Items
is the begins and ends with the request).

Alternatively, you can also use a ThreadStatic for this (although there
is a common
misconception that ThreadStatic cannot be used in asp.net because the
worker
threads are reused, but in fact it is quite easy. So, if you want to
access this data
outside your asp.net web layer (model/data access) a threadstatic might
be the
more "architecturally" elegant solution (since you do not have to
import System.Web namespace):
 
G

Guest

Use static members for the shared data, and instance members for the
user-specific...

HTH,

Paul
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top