Page attribute & concurrency
-
Hi, what if I have a Page subclass A.cs with a protected attribute "foo" and I use it in A.aspx.cs ? what if many users request page A ? what value of "foo" will they see ? Class A:
public class A : System.Web.UI.Page { protected string foo; private void Page_Load(object sender, System.EventArgs e) { foo = "hi there " + Request["AUTH_USER"]; } ...
Page A:<%@ Page language="c#" Codebehind="A.aspx.cs" AutoEventWireup="false" Inherits="some.A" %> <%=foo%> ...
Thanks in advance for your reply -
Hi, what if I have a Page subclass A.cs with a protected attribute "foo" and I use it in A.aspx.cs ? what if many users request page A ? what value of "foo" will they see ? Class A:
public class A : System.Web.UI.Page { protected string foo; private void Page_Load(object sender, System.EventArgs e) { foo = "hi there " + Request["AUTH_USER"]; } ...
Page A:<%@ Page language="c#" Codebehind="A.aspx.cs" AutoEventWireup="false" Inherits="some.A" %> <%=foo%> ...
Thanks in advance for your replyAn instance for the Page class is created for every request. xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
-
An instance for the Page class is created for every request. xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
-
So it does not do some sort of object pooling ? for every request it creates an object from that class, serve the request, destroy the object ? :wtf: well... ok, thanks! ---------------------- !happy coding!
zu78 wrote:
for every request it creates an object from that class, serve the request, destroy the object ?
AFAIK yes, silly isnt it? static instances are persisted on application level, but be aware ASP.NET tends to go into 'sleep' mode and the values get reset. Other option is to use the Session object. You can just save object instances there that will be persisted for the current session of the user, which is porbably what you are looking for :) Eg:
string id = Session["login"] as string;
... -
zu78 wrote:
for every request it creates an object from that class, serve the request, destroy the object ?
AFAIK yes, silly isnt it? static instances are persisted on application level, but be aware ASP.NET tends to go into 'sleep' mode and the values get reset. Other option is to use the Session object. You can just save object instances there that will be persisted for the current session of the user, which is porbably what you are looking for :) Eg:
string id = Session["login"] as string;
...leppie wrote:
You can just save object instances there that will be persisted for the current session of the user, which is porbably what you are looking for
Err... no. What I want is a method of passing objects between a class and it's subclass in a concurrent-access-safe-manner and only in the scope of a request/response (I need something like java's Request.setAttribute). ViewState is great, but IMHO only for intranet applications. But, if your answer is correct... I've found it. Thanks! ---------------------- !happy coding!
-
zu78 wrote:
for every request it creates an object from that class, serve the request, destroy the object ?
AFAIK yes, silly isnt it? static instances are persisted on application level, but be aware ASP.NET tends to go into 'sleep' mode and the values get reset. Other option is to use the Session object. You can just save object instances there that will be persisted for the current session of the user, which is porbably what you are looking for :) Eg:
string id = Session["login"] as string;
... -
J4amieC wrote:
Oxymoron alert
Ok, wise ass, what would you call it? Maybe not techinically correct, but everyone (bar you) seems to understand it as "an instance of a class that is a static member in some class". :doh: xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!
-
J4amieC wrote:
Oxymoron alert
Ok, wise ass, what would you call it? Maybe not techinically correct, but everyone (bar you) seems to understand it as "an instance of a class that is a static member in some class". :doh: xacc-ide 0.0.99-preview7 now with C#, C, C++, IL, XML, Nemerle, IronPython, Perl, Caml, SML, Ruby, Flex, Yacc, Java, Javascript, Lua, Prolog and Boo highlighting support!