如何在 mvc 视图中获取路由和查询字符串值
如果我有这个 URL:
http://stackoverflow.com/question/ask?type=great
如何最经济地获取视图中的完整路由和查询字符串值,例如这个
/question/ask?type=great
If I have this URL:
http://stackoverflow.com/question/ask?type=great
How do I get the complete route and query string values in the View most economically eg this
/question/ask?type=great
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果你想从视图中访问它,你可以使用 httpcontext,
如下所示:
If you want to get to it from the View, you could use httpcontext
like this:
您可以在控制器中设置操作方法来自动为您解析查询字符串。您无需对路线执行任何操作。
获取 mvc 中的查询字符串值
you can set the action method in your controller to automatically parse the query string for you. You don't need to do anything to your route.
get query string values in mvc