Does the asp.net web method always always return jsonified data?

I have a general question, what if webmethod asp.net always returns data in the form of "json". If not what is the default return type for the web method?

I am wondering if there is a way to get data from a web method in "HTML" and not "json"?

thanks

+4
source share
2 answers

PageMethods are part of the ASP.NET AJAX Framework (ScriptManager).

By default, ASP.NET AJAX uses JSON as opposed to SOAP.

This is by design, mainly because the ASP.NET AJAX Javascript library is optimized for working with JSON objects.

You can override this default value by specifying the [ResponseFormat] attribute in the web method.

Like this:

[WebMethod] [ScriptMethod(ResponseFormat = ResponseFormat.Xml)] public XmlElement GetFoo(string url) { 

Here 's a decent article on web services using PageMethods and ASP.NET AJAX.

+2
source

The default return type for the web service must contain SOAP (XML format), for WCF there is a REST package that can change its return type to JSON

[ http://msdn.microsoft.com/en-us/netframework/cc950529.aspx.BIZ[1]

Hope this helps.

0
source

Source: https://habr.com/ru/post/1316155/


All Articles