从查询字符串构建匿名类型
我想知道是否有人有从查询字符串动态构建匿名类型的经验,并且能够排除特定值
例如:
鉴于导致结果屏幕的查询字符串?t1=sadfasdf&t2=sdafasdfasdf&t3=sdfsadfasf&t4=dfasdfasdf
我想提供以下链接
Action?t1=sadfasdf&t2=sdafasdfasdf&t3=sdfsadfasf&t4=dfasdfasd f
行动? t1=Suggestion&t2=sdafasdfasdf&t3=sdfsadfasf&t4=dfasdfasdf
Action?t1=sadfasdf&t2=Suggestion&t3=sdfsadfasf&t4=dfasdfasdf
但如果将附加参数添加到查询字符串中,我希望操作链接到自动将值传递给下一个操作
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 parameter is added to the querystring, I would like the action links to automatically pass the value to the next action
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不必使用匿名类型来传递操作参数,这很方便。您可以使用
RouteValueDictionary
每个 mvc Action 方法都有一个重载,它需要一个RouteValueDictionary
来代替,并且您可以从Url.RequestContext.RouteData.Values 获取当前值
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 aRouteValueDictionary
instead, and you can get the current values fromUrl.RequestContext.RouteData.Values