• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

存储调查数据的最佳方式?

用户头像
it1352
帮助1

问题说明

我正在开发一个非常小的调查应用程序,可能有 3-4 页的 Web 应用程序.所以我的问题是保存调查数据的最佳方法是什么?

I am developing a very small survey application, likely 3-4 pages web application. so my question is what is the best way to save survey data?

顺便说一下,到目前为止我想出了以下方法.

by the way so far I have come up with the following ways.

  1. 保存到数据库并将每个调查标记为未完成.当用户提交调查的最后一个表格时,检查调查的完整性,如果完成则将其标记为完成.

  1. save to database and mark each survey as incomplete. when user submits last form of the survey check completeness of the survey and mark it as complete if it is complete.

保存到会话,然后在用户提交调查的最后一个表格时保存到数据库.

save to sessions and than save to database when user submits last form of the survey.

您如何看待这些方法?

正确答案

#1

我对这类事情感到很头疼,如果可能的话,我建议不要使用 Sessions.当您的网站流量适中,或者 ASP.NET 只是感觉如此时,您可能会发现您丢失了所有会话,因为 .NET 会尝试释放一些内存.

I've had quite some headaches with this sort of thing and would advise against using Sessions if at all possible. When your site gets moderately heavy traffic, or if ASP.NET just feels like it, you may find you lose all your sessions as .NET tries to free up some memory.

我会尽快将其放入数据库.使用 Guid.NewGuid() 生成一个唯一的不可猜测的键,您可以将其从查询字符串中的一页传递到下一页:这将是您从数据库中检索记录的键.

I'd go for putting it in the database as soon as possible. Use Guid.NewGuid() to generate a unique unguessable key that you can pass from one page to the next in the query string: that'll be your key to retrieving the record from the database.

您还没有考虑过的另外两个选项:

Two other options you haven't considered:

  1. 将响应从一页发布到下一页.(这可能比它的价值更麻烦.)

  1. Post the response from one page to the next. (This might be more hassle than it's worth.)

使用 asp:Wizard 控件.这样,您的 3-4 页实际上将是单个页面上的 3-4 个步骤.来自每个阶段的数据会自动为您存储在 ViewState 中,因此当您进行最后一步时,您仍然可以访问第一步中的输入字段.

Use the asp:Wizard control. That way your 3-4 pages will actually be 3-4 steps on a single page. The data from each stage is automatically stored in the ViewState for you, so the input fields from the first step will still be accessible to you when you're on the last step.

(不过我还是会选择你的选项 1.)

(I'd still go for your option number 1 though.)

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /reply/detail/tanhcfhcje
系列文章
更多 icon
同类精品
更多 icon
继续加载