开发者

MVC 3: Setting Data Annotations on objects returned from SOAP Service

开发者 https://www.devze.com 2023-03-05 04:24 出处:网络
I have an MVC 3 web app that calls a SOAP web service to get 开发者_运维问答its data. It would be highly beneficial for me to apply data annotation attributes on returned object properties. Is it poss

I have an MVC 3 web app that calls a SOAP web service to get 开发者_运维问答its data. It would be highly beneficial for me to apply data annotation attributes on returned object properties. Is it possible to do this or should I create a ViewModel for each corresponding object?

How could this be done?


From my own experience it is bad practice to use the objects returned from web services in Views - I tend to have a layer that maps my web service calls to View Models specific to that view

This can make it easier to use data in the view. The general rule is that 1 view model to a view

0

精彩评论

暂无评论...
验证码 换一张
取 消