Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

c#

asp.net-mvc

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

like image 983
Jim Avatar asked Nov 17 '12 13:11

Jim


1 Answers

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")
like image 121
Lukas Winzenried Avatar answered Nov 03 '22 00:11

Lukas Winzenried