我有2个Web API控制器: 1. Runtime1Controller 2. Runtime2Controller
在Runtime2Controller中:
public HttpResponseMessage PostCreateRequest(KeyRequest keyRequest)
{
try
{
Runtime1Controller runtime1Controller = new Runtime1Controller();
HttpResponseMessage response = runtime1Controller.PostCreateRequest(keyRequest);
response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
return response;
}
catch(Exception ex)
{
throw;
}
}
在Runtime1Controller中,我返回HttpResponse消息:
public HttpResponseMessage PostCreateRequest(KeyRequest keyRequest)
{
// Process Data .....
Request.CreateResponse(HttpStatusCode.Created, keyRequest);
}
然后,为什么所有时间请求为NULL。如果我直接调用Runtime1Controller PostCreateRequest,它不是NULL。为什么SO ???
答案 0 :(得分:0)
在Runtime1Controller中,在创建响应时使用return(或者你可能不用这个部分):
public HttpResponseMessage PostCreateRequest(KeyRequest keyRequest)
{
// Process Data .....
return Request.CreateResponse(HttpStatusCode.Created, keyRequest);
}