从查询字符串构建匿名类型

发布于 2024-10-19 18:05:32 字数 454 浏览 0 评论 0原文

我想知道是否有人有从查询字符串动态构建匿名类型的经验,并且能够排除特定值

例如:
鉴于导致结果屏幕的查询字符串?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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

我纯我任性 2024-10-26 18:05:32

您不必使用匿名类型来传递操作参数,这很方便。您可以使用 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 a RouteValueDictionary instead, and you can get the current values from Url.RequestContext.RouteData.Values

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文