Modelbinding for empty query string parameters in ASP.NET MVC 2

为君一笑 提交于 2019-11-30 17:16:39

Null is more representative of what it actually is, and it is compatible with other nullable types besides string, so I imagine it's by design.

I prefer the behavior of v1. How will you be able to pass an empty string in v2? Additionally, with the latter you can't tell whether foo is in the query parameters or not.

One way to configure would be to replace the default model binder in V2 (or V1) to get consistent behavior. I prefer the null, myself.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!