gpt4 book ai didi

asp.net - WebMethod 以字符串形式返回(不带
转载 作者:行者123 更新时间:2023-12-02 12:42:24 24 4
gpt4 key购买 nike

[WebMethod(EnableSession=true)]
[ScriptMethod(UseHttpGet=true, XmlSerializeString = false)]
public string RaiseCallbackEvent(string eventArgument)

返回值以 <?xml 开头。我怎样才能摆脱它?

最佳答案

我猜它这样做是因为它是一个 SOAP Web 服务,而这正是 SOAP Web 服务所期望的。如果您只想将纯文本返回给客户端,我会创建一个 ashx 来手动处理请求。

像这样(这是默认的通用处理程序脚手架)

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
public class Test : IHttpHandler
{

public void ProcessRequest(HttpContext context)
{
context.Response.ContentType = "text/plain";
context.Response.Write("Hello World");
}

public bool IsReusable
{
get
{
return false;
}
}

关于asp.net - WebMethod 以字符串形式返回(不带 <?xml 标签),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1589369/

24 4 0

Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com