开发者

Building Anonymous type from querystring

开发者 https://www.devze.com 2023-02-14 11:20 出处:网络
I was wondering if anyone had experience dynamically building an anonymous type from a query string with the ability to exclude specifc values

I was wondering if anyone had experience dynamically building an anonymous type from a query string with the ability to exclude specifc values

For example:

Given the querystring resulting in a results screen ?t1=sadfasdf&t2=sdafasdfasdf&t3=sdfsadfasf&t4=dfasdfasdf

I want to provide the following links

Action?t1=sadfasdf&t2=sdafasdfasdf&t3=sdfsadfasf&t4=dfasdfasdf

Action?t1=Suggestion&t2=sdafasdfasdf&t3=sdfsadfasf&t4=dfasdfasdf

Action?t1=sadfasdf&t2=Suggestion&t3=sdfsadfasf&t4=dfasdfasdf

but if an addtional p开发者_如何学JAVAarameter is added to the querystring, I would like the action links to automatically pass the value to the next action


You don't have to use an anonymous types to pass action parameters, that's a convenience. You can use a RouteValueDictionary every mvc Action method has an overload that takes a RouteValueDictionary instead, and you can get the current values from Url.RequestContext.RouteData.Values

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号