【发布时间】:2010-06-25 13:48:48
【问题描述】:
我正在尝试创建一个可以执行 HTTP GET 请求的 ASMX 网络服务。我有以下简单的 sn-p 代码来说明我已经完成的工作。
using System.Web.Script.Services;
...
[WebMethod]
[ScriptMethod(UseHttpGet = true)]
public string HelloWorld(HttpContext context)
{
return context.Request.Params.Get("userId").ToString();
}
除此之外,我还在我的 Web.config 文件中添加了以下节点
<webServices>
<protocols>
<add name="HttpGet"/>
<add name="HttpPost"/>
</protocols>
</webServices>
我面临的问题是,每当我尝试调试此 Web 服务时,我都会不断收到可怕的“System.Web.HttpContext cannot be serialized because it does not have a parameterless constructor”错误消息。我不知道问题出在哪里,我非常感谢为使我摆脱这种困境而提供的任何帮助。我意识到 HTTP GET 请求应该非常简单,但我真的不确定我的挫败感是什么。
【问题讨论】:
标签: c# .net web-services asmx http-get