Jim
Jim

Reputation: 16022

add parameters / query string values in action filter. c# mvc3

When I attempt to add either parameters or query string values to the context inside an action filter, an exception gets raised to say that the collection is read only.

I would like to add values to the 'outgoing' url when it is created.

filterContext.ActionParameters.Add("test", "test");

I need these values passed on to the query string, or in the request parameters. Thanks

Upvotes: 9

Views: 6298

Answers (1)

Lukas Winzenried
Lukas Winzenried

Reputation: 1919

HttpContext.Request.Params is read only. It's reflects the incoming request.

Consider using HttpContext.Items to save our own objects/values

filterContext.HttpContext.Items.Add("test","test")

Upvotes: 8

Related Questions