当我传递此请求时,它将 null 传递给服务器站点上的请求参数。数据属性有问题吗?
$.getJSON('http://127.0.0.1:81/api/sites/GetDomainAvailability?apikey=asfasfdsf&callback=?', { "request": '{"SubDomain":"asfsadf","ParentDomain":"asfasdf","ResellerId":"asfdsd"}' }, function (results) {
alert('Cross domain JS call achieved. Have your implementation going in here!');
});
API C#
[HttpGet]
public HttpResponseMessage GetDomainAvailability(GetDomainAvailabilityRequest request)
{
if (ModelState.IsValid)
{
if (request == null) return Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid Request");
var domain = string.Format("{0}.{1}", request.SubDomain, request.ParentDomain);
var manager = new CloudSitesManager();
var isDomainAvailable = manager.GetDomainAvailability(domain);
HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, isDomainAvailable);
return response;
}
else
{
return Request.CreateResponse(HttpStatusCode.BadRequest);
}
}
[Serializable]
public class GetDomainAvailabilityRequest
{
public string SubDomain { get; set; }
public string ParentDomain { get; set; }
public string ResellerId { get; set; }
}