Archives

Archives / 2004 / October
  • Session sharing between ASP and ASP.NET

    The question comes back every so often, so I thought I'd post about it.
     
    Almost all existing solutions are intrusive and need to modify the code of the ASP application, the ASP.NET application or both. All solutions incur a performance cost as the data has to be marshaled between the COM world of ASP and the .NET world of ASP.NET.
     
    First, there’s a solution in MSDN: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnaspp/html/converttoaspnet.asp but it necessitates modifications on both sides and needs a database, which could degrade the application’s performance.
     
    There are also a few commercial products, all in the $200 to $300 range:
     
    http://www.consonica.com/solutions/statestitch/ which just requires one include on top of each ASP page that uses the session. One drawback is that it doesn’t support COM objects in the session, except for Dictionary.
     
    http://www.sessionbridge.com/ which requires more code changes to all places where the ASP session is used.
     
    And then, there is my own approach, which is the only one that I know of that requires no source code change anywhere (except a few very particular cases), but it’s just a proof of concept, nothing I would use in a production environment (we have no performance data):
    http://www.dotnetguru.org/articles/us/ASP2ASPNET/ASP2ASPNET.html
     
    And a very similar attempt which may scale better:
     
    My own approach is shared source, so anyone is free to improve on it.

    Read more...

  • ViewState restoration does not call any setters


    public bool Selected {
     
    get {
       
    object o = ViewState["Selected"];
       
    if (o == null) {
         
    return false;
        }
       
    return (bool)o;
      }
     
    set {
        ViewState["Selected"] =
    value;
       
    if (Owner == null) return;
       
    if (value) {
          Owner.SetSelectedNode(
    this);
        }
       
    else if (this == Owner.SelectedNode) {
          Owner.SetSelectedNode(
    null);
        }
      }
    }

    Read more...

  • A few things I remember about quantum mechanics

    A post on the ASP.NET forums recently went a little crazy by shifting from a perfectly normal question on how to get the response object from a class that doesn't derive  from Page or Control (to which the answer is to use HttpContext.Current.Response) to quantum mechanics and the multiverse theories.
    I happen to know a few things on quantum mechanics, dating back from my PhD, so I can shed some light on these subjects (or make them even more obscure, we'll see).
     
    Here are a few things that have been said in this thread and a few comments:
    "Light will act like a wave until observed, at which time it collapses to a point."
    It would be more precise to say a photon, or quantum of light, that is, the minimum quantity of light you can get.
     
    "wherever an elemental "decision" is made (whether the light went through the top or bottom hole of the twin-hole experiment; or whether Schrodinger's cat is alive or dead), the universe splits to accommodate both decisions."
    That was the original idea of the multiverse, but we'll see that there may be a much better and simple explanation.
     
    "Another "solution" to the riddle proposed by Schrodinger's cat is the idea that light travels backwards in time, just as it travels forward."
    For that to solve any problem, all particles would have to be able to travel back in time: light is not the only way to transmit information. As a matter of facts, virtual particles are able to travel faster than light, but there's no way to observe these directly, so they can't convey any information. As far as we know, no faster than light phenomenon can transport any information. Another way to say that is that no signal can travel faster than light. If it travels faster than light, it's not a signal. One example uses a pulsar as a beacon: the pulsar sends a jet of particles in some direction which rotates with the pulsar (like a beacon). Imagine now some enormous projection screen (interstellar gas clouds play this role very well) that is able to emit some light when the particle jet hits it. If the screen is far enough from the pulsar, the spot of light it projects on the screen can move well above the speed of light (its speed is the angular rotation speed of the pulsar times the distance from it to the screen). The explanation is that the spot of light you see at one point in time was not created by the same particles as a little later. In other words, what you see is not an object moving, what you see is a succession of different objects that give the illusion of movement (the real movement is perpendicular to the screen, whereas the one you think you see is parallel to it). A similar phenomenon gives the illusion that a particle can quantum-tunnel through a barrier faster than light. It's a little trickier to explain but in this case too, no faster than light signal can be transmitted.
     
    "I know that the multiverse theory has moved on from that, and rather than splitting universes there are now bubbling multiverses and virtual multiverses"
    True, now it's a completely different theory, based on string theory. It states that there is only one universe (which is the definition of the universe after all) that has different, causally disconnected regions in which the laws of physics are different. These new "bubbles" can appear when a region of an existing bubble tunnels into a state with a lower vacuum energy, which results in the rapid expansion of this bubble as the extra energy is transformed into space, so fast that it disconnects it from the bubble that formed it. There's an excellent article about that in the September issue of Scientific American.
     
    "I mean Schrodinger was trying to explain the role of the observer in deciding the quantum state of a particle. In his experiment he assumed that the only observer was the experimenter that opened the box - until the box was opened the particle was 'in' a state of quantum uncertainty. But, what I always say when someone mentions the experiment - what about the cat???!!! Surely, it knows whether it is alive or dead!"
    Absolutely, this is what makes Schrödinger's cat thought experience completely bogus as it's usually told: the cat is an observer and is classic enough to collapse the particle's state. It's never half-dead, half alive.
    But there are real Schrödinger's cats that actually fulfill exactly the original prediction. The difference is that they are not cats, but rather small lumps of matter. Scientists are now able to make these lumps bigger and bigger, but it will always be impossible to do the experiment with an actual cat.
    What happens when you measure a quantum phenomenon has been fascinating since it was discovered, more than any other aspect of quantum physics. The reason is clearly that it is the only case in modern physics where pure chance seems to have a role: it looks undeterministic. Of course, this has been hastily interpreted by many as the finger of God, or as what enables us to have free will. I'll get back to that as soon as I've exposed a more modern theory of quantum measurement that seems to give very good results while making it all deterministic again. I can't find the references of papers about this so I'll rely on my memory here. If someone reads this and knows where to find the relevant papers, please drop me a note.
    The idea is that a measurement device is a quantum system (like everything) that has many degrees of freedom and that a measurement is actually a complex interaction with such an object. What happens is that this interaction results in the quantum object to collapse into a classical state. This theory is able to predict the time that it takes the object to collapse, and how complex an object has to be to cause the collapse. Experimental data seems to confirm this theory (I think the experiments were done at the Ecole Normale Supérieure de Paris).
    So according to this theory, there is nothing strange or random in a measurement, it's just one quantum interaction like everything. In a way, the chaos of the state of the device replaces chance. And everything is deterministic again.
    Including the human brain.
    So where does that leave our freedom of choice? Well, we would have none, obviously, if we are made of quantum particles like the rest of the universe. But that's not a problem, the illusion of it is enough.

    Read more...

  • Sorry about the comments on old posts

    For some obscure reasons that have to do with spam but that I failed to understand, comments are not allowed anymore on posts older than 30 days on weblogs.asp.net blogs.
    This is very frustrating and goes against the very principle of blogs. I'm really sorry about that, but there's nothing I can do oher than send internal mail to complain about it (which I already did). I just hope that this limitation is removed as soon as possible.
    For now, if you have comments, you can send them to me using the contact feature of the blog, and I'll store them until I can post them for you (yes, amazing as it may seem, even I can't comment my own blog).

    Read more...