会话对象中的经典 ASP Store 对象 [英] Classic ASP Store objects in the session object

查看:27
本文介绍了会话对象中的经典 ASP Store 对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是经典 ASP 的新手,我需要使用经典 ASP 编写 Web 应用程序,因为客户希望它使用经典 ASP.:(

I am new to classic ASP and I need to code a web application in classic asp because the customer wants it to be in classic asp. :(

无论如何!这是我的问题:

Anyways! here is my question:

当我有一个名为 person 的类的对象时:

When I have a object of a class called person:

Class Person
 Private m_sFirstName

 Public Property Get firstName
 firstName = m_sFirstName
 End Property

 Public Property Let firstName(value)
   m_sFirstName = value
 End Property

End Class


set aPerson = new Person
Person.firstName = "Danny"

set Session("somePerson") = aPerson

<小时>

到目前为止一切都很好...


So far so good...

在下一个请求中,我尝试读取会话变量:

On the next request , I try to read the session var like :

If IsObject(Session("aPerson")) = true Then
    set mySessionPerson = Session("aPerson")

      Response.Write(TypeName(myTest)) // will output "Person" 
      Response.Write(mySessionPerson.firstName) // will output "Object doesn't support this property or method: 'mySessionPerson.firstName'
End If

任何关于正在发生的事情的想法都会有很大帮助.

Any ideas about what is going would be of great help.

推荐答案

我无法解释为什么你的代码在我看来不起作用.

该对象是在脚本上下文中创建的,该上下文随后在请求完成后被拆除.因此,虽然类型名称可用,但对象的功能已损坏.

The object is created in a script context which is subsequently torn down after the request is complete. Hence whilst the type name is available the object's function is broken.

我可以告诉你,即使是那些不是在脚本中创建的对象,将对象存储在 Session 中也不是一个好主意.

I can tell you its not a good idea to store objects in the Session even those not created in script.

ASP 中使用的大多数对象都存在于单个线程中.一旦创建,只有创建对象的线程可以访问该对象.为了解决这个问题,一旦您在会话中存储了一个对象,ASP 就会将该会话与创建该对象的特定工作线程关联起来.

Most objects used in ASP exist in a single thread. Once created only the thread that created the object may access the object. To cope with this once you have stored an object in the session ASP affiliates the session with the specific worker thread that created it the object.

当对该会话的后续请求到达时,它现在必须由其特定的工作线程处理.如果该线程正忙于处理其他一些请求,则会话请求将排队,即使有大量其他可用的工作线程也是如此.

When a subsequent request for that session arrives it must now be handled by its specific worker thread. If that thread happens to be busy working for some other request the sessions request is queued, even if there a plenty of other available worker threads.

总体影响是破坏了应用程序的可扩展性,工作负载可能会在工作线程之间分布不均.

The overall effect is to damaging the applications scalability where the work load can become unevenly distributed across the worker threads.

这篇关于会话对象中的经典 ASP Store 对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆