2011-08-10 16 views
0

我有一个Silverlight 4.0应用程序正在使用客户端上的Hammock API发出RESTful服务代码,对MVC3应用程序进行REST式调用。我如何使Hammock发出HTTP GET

问题是无论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); 
} 
+0

什么是'RestRequest'?这是你编码的东西,还是它是第三方组件的一部分? – AnthonyWJones

+0

RestRequest是Hammock API库的一部分 –

回答

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); 
}