In my ASP.NET MVC 5 application I want to use some parameters to "survive" several subsequent requests irrespective of whether they were processed in controller or not.
在我的ASP。NET MVC 5应用程序我想使用一些参数来“生存”几个后续请求,不管它们是否在控制器中处理。
For example, if the request has order/add/1234?promocode=new2014
in it, I want it to stay all the way the user puts together his or her order until he proceeds to check-out. This means, that every action link generated using HTML helpers in my views should contain this parameter.
例如,如果请求有order/add/1234?promocode=new2014在其中,我希望它一直保持到用户完成他或她的订单为止。这意味着,在我的视图中使用HTML helper生成的每个动作链接都应该包含这个参数。
How can I achieve this?
我如何做到这一点?
1 个解决方案
#1
1
You could save this parameter in Viewbag and then use it again like
您可以将这个参数保存到Viewbag中,然后像这样再次使用它
@Url.Action("index",new {promocode = Viewbag.CurrentPromocode})
。行动(“指数”,新{ promocode = Viewbag.CurrentPromocode })
#1
1
You could save this parameter in Viewbag and then use it again like
您可以将这个参数保存到Viewbag中,然后像这样再次使用它
@Url.Action("index",new {promocode = Viewbag.CurrentPromocode})
。行动(“指数”,新{ promocode = Viewbag.CurrentPromocode })