演示经典ASP网站的好方法

时间:2021-04-23 02:03:03

What is the best way to save data in session variables in a classic web site?

在经典网站中保存会话变量中数据的最佳方法是什么?

I am maintaining a classic web site and want to be able to allow my users to demo all functionality of the site, this means allowing them to delete records.

我正在维护一个经典的网站,并希望能够允许我的用户演示网站的所有功能,这意味着允许他们删除记录。

The closet example I have seen so far are the demos of Telerik controls where they are saving the dataset in sessions on first load and allowing the user to manipulate the data.

我到目前为止看到的壁橱示例是Telerik控件的演示,他们将数据集保存在第一次加载的会话中,并允许用户操作数据。

How can I achieve the same in ASP with an MS Access backend?

如何在ASP中使用MS Access后端实现相同的功能?

3 个解决方案

#1


If you want to persist the state over multiple pages (e.g. to demo you complete application) then it's a bit tricky.

如果你想将状态保存在多个页面上(例如,演示你完成应用程序)那么它有点棘手。

I would suggest copying the MDB file for each session and using the copied version. This would ensure that every session uses its own data.

我建议为每个会话复制MDB文件并使用复制的版本。这将确保每个会话都使用自己的数据。

  • create a version of your access db which will be used as a fresh template for each user
  • 创建访问数据库的一个版本,该版本将用作每个用户的新模板

  • on session copy the template and name it after the users session ID
  • 在会话中复制模板并在用户会话ID后命名

  • use the individual MDB
  • 使用单独的MDB

Note: Then only drawback I can see here is that you need to remove the unused MDB files as it can get a lot after sometime. You could do it with a scheduled task or even on session start before you create a new one.

注意:那么我可以看到的唯一缺点是你需要删除未使用的MDB文件,因为它可以在一段时间后获得很多。您可以在创建新任务之前使用计划任务甚至在会话启动时执行此操作。

I am not sure what you can use to check if it's used or not but check the files creation date or maybe the LDF file can help you as well (if it does not exist = unused).

我不知道你可以用什么来检查它是否被使用但检查文件创建日期或者LDF文件也可以帮助你(如果它不存在=未使用)。

#2


You can store a connection or inclusive an object in a session variable as far you remember what kind of variable are you storing at the retrieving time. I had never stored a dataset in a session variable but I had stored a lot of arrays in session variables so you can use the ADO Getrows method to locate a complete dataset into a session variable.

您可以在会话变量中存储连接或包含对象,以便记住在检索时存储的变量类型。我从来没有在会话变量中存储数据集,但是我在会话变量中存储了很多数组,因此您可以使用ADO Getrows方法将完整的数据集定位到会话变量中。

#3


How big is the Access database? If your database is small enough (relative to the server capacity, expected number of users, and so forth) then I like the idea of using a fresh copy of the database for each user that runs the demo.

Access数据库有多大?如果您的数据库足够小(相对于服务器容量,预期的用户数等等),那么我喜欢为运行该演示的每个用户使用数据库的新副本。

With this approach, you simplify your possible code paths. Otherwise this "are we in demo mode or not?" logic will permeate a heck of a lot of your code.

使用此方法,您可以简化可能的代码路径。否则这“我们是否处于演示模式?”逻辑将渗透到你的很多代码中。

I'd do it like this...

我这样做......

  1. When the user begins the demo, make a copy of the Access DB for that user to use. If your db is foo.mdb, copy it to /tempdb/foo_1234567890.mdb where 1234567890 is the user's session ID.

    当用户开始演示时,请为该用户制作Access DB的副本以供使用。如果您的数据库是foo.mdb,请将其复制到/tempdb/foo_1234567890.mdb,其中1234567890是用户的会话ID。

  2. Alter the user's connection string to point to the fresh database copy. From this point on, your app can operate like "normal" with no further modifications.

    更改用户的连接字符串以指向新数据库副本。从现在开始,您的应用程序可以像“正常”一样运行,无需进一步修改。

  3. Have a scheduled task that deletes all files in /tempdb with last-modified times more than __ hours in the past. If you don't have the ability to schedule tasks on the server (perhaps you're in a shared hosting environment, etc) then you could do this at the same time you do step #1.

    有一个计划任务,删除/ tempdb中的所有文件,上次修改时间超过__小时。如果您无法在服务器上安排任务(可能您处于共享托管环境等),那么您可以在执行步骤#1的同时执行此操作。

#1


If you want to persist the state over multiple pages (e.g. to demo you complete application) then it's a bit tricky.

如果你想将状态保存在多个页面上(例如,演示你完成应用程序)那么它有点棘手。

I would suggest copying the MDB file for each session and using the copied version. This would ensure that every session uses its own data.

我建议为每个会话复制MDB文件并使用复制的版本。这将确保每个会话都使用自己的数据。

  • create a version of your access db which will be used as a fresh template for each user
  • 创建访问数据库的一个版本,该版本将用作每个用户的新模板

  • on session copy the template and name it after the users session ID
  • 在会话中复制模板并在用户会话ID后命名

  • use the individual MDB
  • 使用单独的MDB

Note: Then only drawback I can see here is that you need to remove the unused MDB files as it can get a lot after sometime. You could do it with a scheduled task or even on session start before you create a new one.

注意:那么我可以看到的唯一缺点是你需要删除未使用的MDB文件,因为它可以在一段时间后获得很多。您可以在创建新任务之前使用计划任务甚至在会话启动时执行此操作。

I am not sure what you can use to check if it's used or not but check the files creation date or maybe the LDF file can help you as well (if it does not exist = unused).

我不知道你可以用什么来检查它是否被使用但检查文件创建日期或者LDF文件也可以帮助你(如果它不存在=未使用)。

#2


You can store a connection or inclusive an object in a session variable as far you remember what kind of variable are you storing at the retrieving time. I had never stored a dataset in a session variable but I had stored a lot of arrays in session variables so you can use the ADO Getrows method to locate a complete dataset into a session variable.

您可以在会话变量中存储连接或包含对象,以便记住在检索时存储的变量类型。我从来没有在会话变量中存储数据集,但是我在会话变量中存储了很多数组,因此您可以使用ADO Getrows方法将完整的数据集定位到会话变量中。

#3


How big is the Access database? If your database is small enough (relative to the server capacity, expected number of users, and so forth) then I like the idea of using a fresh copy of the database for each user that runs the demo.

Access数据库有多大?如果您的数据库足够小(相对于服务器容量,预期的用户数等等),那么我喜欢为运行该演示的每个用户使用数据库的新副本。

With this approach, you simplify your possible code paths. Otherwise this "are we in demo mode or not?" logic will permeate a heck of a lot of your code.

使用此方法,您可以简化可能的代码路径。否则这“我们是否处于演示模式?”逻辑将渗透到你的很多代码中。

I'd do it like this...

我这样做......

  1. When the user begins the demo, make a copy of the Access DB for that user to use. If your db is foo.mdb, copy it to /tempdb/foo_1234567890.mdb where 1234567890 is the user's session ID.

    当用户开始演示时,请为该用户制作Access DB的副本以供使用。如果您的数据库是foo.mdb,请将其复制到/tempdb/foo_1234567890.mdb,其中1234567890是用户的会话ID。

  2. Alter the user's connection string to point to the fresh database copy. From this point on, your app can operate like "normal" with no further modifications.

    更改用户的连接字符串以指向新数据库副本。从现在开始,您的应用程序可以像“正常”一样运行,无需进一步修改。

  3. Have a scheduled task that deletes all files in /tempdb with last-modified times more than __ hours in the past. If you don't have the ability to schedule tasks on the server (perhaps you're in a shared hosting environment, etc) then you could do this at the same time you do step #1.

    有一个计划任务,删除/ tempdb中的所有文件,上次修改时间超过__小时。如果您无法在服务器上安排任务(可能您处于共享托管环境等),那么您可以在执行步骤#1的同时执行此操作。