0

我有一个 Silverlight 4.0 应用程序,它使用客户端上的 RESTful 调用 MVC3 应用程序Hammock API来发出 RESTful 服务代码。

问题是无论request.Method设置为WebMethod.Get还是WebMethod.Post,发送的请求都是POST. 我究竟做错了什么?

private IAsyncResult GetServerList()
{
    var callback = new RestCallback((restRequest, restResponse, userState) =>
                {
                    // There is some working callback code here.  Excluded for clarity.
                }
            );

    var request = new RestRequest();
    request.Method = WebMethod.Get;
    request.Path = "ServerList";
    return _restClient.BeginRequest(request, callback);
}
4

1 回答 1

0

尝试在 RestClient 上设置请求类型。

var restClient = new RestClient
        {
            Method = WebMethod.Get
        };

或者从你的例子:

private IAsyncResult GetServerList()
{
    var callback = new RestCallback((restRequest, restResponse, userState) =>
            {
                // There is some working callback code here.  Excluded for clarity.
            }
    );

    var request = new RestRequest();
    request.Path = "ServerList";

    _restClient.Method = WebMethod.Get;
    return _restClient.BeginRequest(request, callback);
}
于 2012-01-24T23:02:41.487 回答