• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

ASP.NET; passing objects in session

Collapse
X
  •  
  • Filter
  • Time
  • Show
Clear All
new posts

    ASP.NET; passing objects in session

    Quick question - currently working on a web development project in classic ASP (yeah, I know, someones gotta do it)

    Anyway, in the usual way that clients do, the spec has moved/grown to a point where it now looks nothing like the original ("can we just add this ...")
    I was originally passing data from page to page with form variables (the original spec didn't have that many fields and wasn't that complex, so was reasonably feasible)

    Now, the number of fields, and the number of pages passing to and from is huge, and it should really be an object. I've created a class in asp with appropriate fields, getter and setter methods; and all works fine. I'd like to hold the object in the session so that subsequent pages have access to it.
    And thats where I'm failing - with classic ASP you cannot set a session variable with an object.

    I've think I've read that with ASP.NET you can store an object in a session variable - but I wanted to check first. Anyone know if this is true ?

    I've already half-persuaded the client that the app in classic ASP has reached the end of its era !!; and it looks like the contract will be extended to include me porting it to .NET anyway - whoopee, I get paid to learn .NET !!

    #2
    Originally posted by Jakes Daddy
    with classic ASP you cannot set a session variable with an object.
    Are you sure? Not done it for a while, so can't remember how, but establishing a "session" rather than just reacting to each request was part of the whole raison d'etre for ASP and the like.
    Will work inside IR35. Or for food.

    Comment


      #3
      No, you definately can't do it:

      http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=195

      Which is an arse !

      I need to be sure that it can be done with .NET so that I can assure the client that paying me to move the app to .NET is a good thing !

      Comment


        #4
        Yes JD, you can store objects in ASP.NET session as the .NET framework is free threaded and everything compiles down to IL.

        In classic ASP the problem is the threading model (apartment threaded). You can write your classes in VB6 and store these COM object instances in ASP session, but it is not scalable due to the threading model.

        You can of course do almost anything in .NET

        Alternatively, in classic ASP why not store the data as an XML string and use the XML parser to read and write the string data to and from session state?

        Comment


          #5
          Originally posted by DimPrawn
          Alternatively, in classic ASP why not store the data as an XML string and use the XML parser to read and write the string data to and from session state?
          I did consider this (was not originally thinking of XML, was thinking of a simple delimited string, but XML would be a better choice) - but I seem to think that there is a limit to the size of a session var ? (not sure where I read this) The app now has a large number of fields, some of which are free text 'comments' style fields - therefore concatenating the lot into delimited string (or creating an XML document from them) would result in a very very long string

          Comment


            #6
            Originally posted by Jakes Daddy
            No, you definately can't do it:

            http://www.aspfaqs.com/aspfaqs/ShowFAQ.asp?FAQID=195

            Which is an arse !
            So it's not that you can't store data in the session, it's that you can store objects defined from a class in the session. So I'm not entirely wrong.

            Now the mists of time are clearing a bit - this was what property bags are for is it not?
            Will work inside IR35. Or for food.

            Comment


              #7
              Originally posted by Jakes Daddy
              I've think I've read that with ASP.NET you can store an object in a session variable - but I wanted to check first. Anyone know if this is true ?
              Yes you can store any objects in the session state in ASP.NET.

              Comment


                #8
                Originally posted by Jakes Daddy
                I did consider this (was not originally thinking of XML, was thinking of a simple delimited string, but XML would be a better choice) - but I seem to think that there is a limit to the size of a session var ? (not sure where I read this) The app now has a large number of fields, some of which are free text 'comments' style fields - therefore concatenating the lot into delimited string (or creating an XML document from them) would result in a very very long string
                There are many ways to skin this cat, too Here are two, from both sides of the spectrum.

                1. Use COM+ Shared Property Manager, straight from ASP.
                CONS: Requires XP or W2003. There may be appartment issues with ASP

                2. Use MDB file.
                Wot Access? Yes! Design a Simple solution. ADO code. ODBC and the lot. Ah, legacy,legacy

                Of, course it would be a little bit faster to switch to .NET. But beware! There are some neat ASP tricks (not hacks) which are no longer possible in .NET.
                Meta Contractor

                Comment


                  #9
                  Of, course it would be a little bit faster to switch to .NET. But beware! There are some neat ASP tricks (not hacks) which are no longer possible in .NET.
                  I'd like to know what these neat tricks in ASP are that are no longer possible in ASP.NET and I'll let you know how to do them.

                  Comment

                  Working...
                  X