ASP.NET MVC3 ModelState 和 RouteData 放置
在 MVC3 中,路由数据是否始终位于 modelState 集合中,或者仅在 modelState 集合中(如果根据适用控制器操作的模型绑定器专门请求该键)?
举例说明:
public HomeController { ActionResult Index(string id)
主页/索引/5?something=else
modelState 字典是否有键 some 和值 else,还是只有键 id?
in MVC3, is route data always in the modelState collection, or is it only in the modelState collection if that key is specifically requested as per the model binder for the applicable controller action ?
To illustrate:
public HomeController { ActionResult Index(string id)
Home/Index/5?something=else
Would the modelState dictionary have the key something and value else, or would it only have the key id?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
仅当它是操作方法参数的一部分时,它才会出现在 ModelState 中。要获取其他路线信息,您需要查看控制器的
RouteData
属性。It is only in the
ModelState
when it is part of the action method argument(s). To get other route info, you need to look at the controller'sRouteData
property.