Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Page attribute & concurrency

Page attribute & concurrency

Scheduled Pinned Locked Moved C#
csharpdesignquestion
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sgatto159
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • S sgatto159

      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

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      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!

      S 1 Reply Last reply
      0
      • L leppie

        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!

        S Offline
        S Offline
        sgatto159
        wrote on last edited by
        #3

        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!

        L 1 Reply Last reply
        0
        • S sgatto159

          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!

          L Offline
          L Offline
          leppie
          wrote on last edited by
          #4

          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;
          ...

          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!

          S J 2 Replies Last reply
          0
          • L leppie

            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;
            ...

            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!

            S Offline
            S Offline
            sgatto159
            wrote on last edited by
            #5

            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!

            1 Reply Last reply
            0
            • L leppie

              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;
              ...

              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!

              J Offline
              J Offline
              J4amieC
              wrote on last edited by
              #6

              leppie wrote:

              static instances

              Oxymoron alert

              L 1 Reply Last reply
              0
              • J J4amieC

                leppie wrote:

                static instances

                Oxymoron alert

                L Offline
                L Offline
                leppie
                wrote on last edited by
                #7

                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!

                J 1 Reply Last reply
                0
                • L leppie

                  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!

                  J Offline
                  J Offline
                  J4amieC
                  wrote on last edited by
                  #8

                  lol calm down... it was a bit of sarcasm.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups