如何处理ASP.NET MVC中的多部分表单?

时间:2022-02-07 04:03:56

I want to make a sign-up form that spans across 3 pages in ASP.NET MVC.

我想在ASP.NET MVC中创建一个跨3页的注册表单。

What method should one use to persist the users answers for the first and second pages before submitting the 3rd page?

在提交第3页之前,应该使用什么方法来保留用户对第一页和第二页的答案?

Is it done with TempData, Session, or some other method particular to MVC?

它是用TempData,Session还是MVC特有的其他方法完成的?

Are there any examples of how to do this?

有没有如何做到这一点的例子?

3 个解决方案

#1


3  

Steven Sanderson has a worked out example in Pro ASP.NET MVC Framework (pp 396-406). He sends the data to the page or serializes to TempData as required, and uses a pair of custom OnActionExecuting/OnResultExecuted methods to manage it behind the scenes. Inside the controller the data pops up like magic, so it is less transparent than I would like, but shows a basic persistence method that avoids session state.

Steven Sanderson在Pro ASP.NET MVC Framework(第396-406页)中有一个很好的例子。他将数据发送到页面或根据需要序列化到TempData,并使用一对自定义的OnActionExecuting / OnResultExecuted方法在后台管理它。在控制器内部,数据像魔术一样弹出,因此它不像我想的那么透明,但显示了一种避免会话状态的基本持久性方法。

#2


0  

Check out this SO Question.

看看这个SO问题。

Design suggestion for passing parameters in MVC

设计建议在MVC中传递参数

#3


0  

I think there are a few criteria you should consider before choosing a solution. Some of these are:

我认为在选择解决方案之前,您应该考虑一些标准。其中一些是:

  1. Do you have authenticated users or public (anonymous) users?
  2. 您是否有经过身份验证的用户或公共(匿名)用户?

  3. How sensitive is the information you're storing between pages?
  4. 您在页面之间存储的信息有多敏感?

  5. Are they allowed to go off-line and return later to continue where they left off?
  6. 他们是否可以离线并稍后返回继续他们离开的地方?

  7. How large is the data you're storing (in total) and how many concurrent users do you anticipate?
  8. 您要存储的数据(总计)有多大,您预计会有多少并发用户?

These questions will lead you to decisions on where and how to store the data. Once you know that, you can start looking for a good implementation of that storage method.

这些问题将引导您决定存储数据的位置和方式。一旦你知道了,你就可以开始寻找这种存储方法的良好实现。

#1


3  

Steven Sanderson has a worked out example in Pro ASP.NET MVC Framework (pp 396-406). He sends the data to the page or serializes to TempData as required, and uses a pair of custom OnActionExecuting/OnResultExecuted methods to manage it behind the scenes. Inside the controller the data pops up like magic, so it is less transparent than I would like, but shows a basic persistence method that avoids session state.

Steven Sanderson在Pro ASP.NET MVC Framework(第396-406页)中有一个很好的例子。他将数据发送到页面或根据需要序列化到TempData,并使用一对自定义的OnActionExecuting / OnResultExecuted方法在后台管理它。在控制器内部,数据像魔术一样弹出,因此它不像我想的那么透明,但显示了一种避免会话状态的基本持久性方法。

#2


0  

Check out this SO Question.

看看这个SO问题。

Design suggestion for passing parameters in MVC

设计建议在MVC中传递参数

#3


0  

I think there are a few criteria you should consider before choosing a solution. Some of these are:

我认为在选择解决方案之前,您应该考虑一些标准。其中一些是:

  1. Do you have authenticated users or public (anonymous) users?
  2. 您是否有经过身份验证的用户或公共(匿名)用户?

  3. How sensitive is the information you're storing between pages?
  4. 您在页面之间存储的信息有多敏感?

  5. Are they allowed to go off-line and return later to continue where they left off?
  6. 他们是否可以离线并稍后返回继续他们离开的地方?

  7. How large is the data you're storing (in total) and how many concurrent users do you anticipate?
  8. 您要存储的数据(总计)有多大,您预计会有多少并发用户?

These questions will lead you to decisions on where and how to store the data. Once you know that, you can start looking for a good implementation of that storage method.

这些问题将引导您决定存储数据的位置和方式。一旦你知道了,你就可以开始寻找这种存储方法的良好实现。