0

I want to supply a value in RedirectToAction() to some other method. My requirement is like this. I al registering a new user.On clicking the next button, I have to register the new user as well as to redirect to some other page with the registration details.So, here I have to supply value in RedirectToAction to get the registration details in new page.Can anyone help me in doing this??

My form is like this:-

New User Reg.:- email password

Next

So, on clicking the next button, I can register the new user but I can't supply the value. How can I do this?? Any help would be greatly appreciated.

In the next form, I have to get those registration details.I can get them but I can't first supply the value to that method.

4

2 回答 2

0

我认为最好的方法是使用 TempData。它在幕后使用会话来保存您需要的任何信息。请注意,一旦您读取数据,TempData 就会被清除。使用它的一个例子是:

TempData["MyKey"] = WhateEverYouWantSaved;
RedirectToAction ("Action","Controller");

在您的操作方法中:

Model m = TempData["MyKey"]; //Cast to Model type if need be

它的优点是不将您的数据包含在 URL 中,这意味着来回传输的数据更少,数据超过 URL 最大长度的可能性更小,如果您不希望用户看到数据,那几乎是您的唯一的选择。

于 2013-05-20T08:08:00.070 回答
0

您可以使用Query Stringlike传递详细信息

return this.RedirectToAction
  ("Actionname", new { yourvalue = "querystringvalue" });

it Would return:
/controller/Actionname?value1=querystringvalue

我假设没有名为yourvalue.

希望您理解并为您工作。

于 2013-05-20T06:13:48.727 回答