Alexander Galkin
Alexander Galkin

Reputation: 12554

How to keep a querystring parameter in subsequent requests in ASP.NET MVC 5?

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.

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.

How can I achieve this?

Upvotes: 2

Views: 1721

Answers (1)

Damian Trzepała
Damian Trzepała

Reputation: 256

You could save this parameter in Viewbag and then use it again like

@Url.Action("index",new {promocode = Viewbag.CurrentPromocode})

Upvotes: 1

Related Questions