Why does WebApi fail to bind a System.Version parameter?

余生长醉 提交于 2019-12-06 10:46:58

To prevent anyone else from trying to answer this, the answer is that the System.Version class has no public setters on its members. Hence it cannot be de-serialized properly, and remains in its initial state. I had to use my own "Version" class that had publicly-settable members, and that worked fine.

I dont think [Serializable] could be an issue.

Try putting 'Content-Type: application/json' as header from the client side. Also use [FromBody] attribute like this.

[HttpPost]
[ActionName("Details")]
public ServiceDto Get([FromBody]Version version)
{
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!