ASMX Returning a pure string

我怕爱的太早我们不能终老 提交于 2019-12-05 09:43:44

Does it need to be an .asmx web service for this? I mean, by excluding the SOAP envelope you're essentially saying "this is not a SOAP web service" as it is, so why not take it a step further and make it a regular .aspx page instead of an .asmx web service.

As a page, what you're trying to do would be trivial. Remove all mark-up from the page, use Response.Headers to edit the response headers accordingly, Response.Write() to output your raw text, and Response.End() to close the response.

Use json

add the required attribute to your web service and your web method and you get what you want.

Web Service Attribute:[ScriptService]

Web Method Attribute:[ScriptMethod(ResponseFormat = ResponseFormat.Json)]

Read a sample Here

Why do you want to get rid of the XML part? The code which is generated by the proxy needs a common format so it can understand and read the data that is being returned. Stripping the XML essentially makes your return data unreadable by the client proxy.

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