What are all the valid ASP.NET Webmethod return types?

≡放荡痞女 提交于 2019-12-22 18:47:48

问题


Can my webmethod only return strings like I see in all the asp.net site examples?


回答1:


asp.net Webmethods can return any serializable data type.




回答2:


Assuming that this question is about the legacy ASMX web service technology, see Data Types Supported by XML Web Services Created Using ASP.NET.

Be sure to take note of where it says:

This topic is specific to a legacy technology. XML Web services and XML Web service clients should now be created using Windows Communication Foundation (WCF).




回答3:


As far as I know, you can pretty much return any .NET class, including anonymous types. I've returned custom objects representing my business entities, including generic collections of children entities. Guids, ints, strings, etc. Anything that can be serialized into a string basically.



来源:https://stackoverflow.com/questions/281978/what-are-all-the-valid-asp-net-webmethod-return-types

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