ASP MVC - 根据查询参数调用不同的操作处理程序?
我希望根据查询参数值采取不同的操作来处理请求。
例如:
mydomain.com/controller/action?version
=1&msg= hello 和
mydomain.com/controller/action?version=2&msg=5
应根据版本值转到不同的处理程序。
必需/可选的查询参数列表及其类型可能会更改 - 在 version=1 中,msg 是一个字符串,在 version=2 中它是一个整数
I would like different a different action to handle a request depending on query parameters values.
For example:
mydomain.com/controller/action?version=1&msg=hello
and
mydomain.com/controller/action?version=2&msg=5
should go to a different handlers based on the version value.
The list of query params required/optional, as well as their types might change - in version=1, msg is a string, in version=2 it is an integer
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用路由约束:
You could use Route Constraints: