使用URL和post参数返回HttpResponseMessage

时间:2017-07-05 07:17:24

标签: redirect asp.net-web-api http-status-code-301 http-redirect httpresponsemessage

我有一个从我的UI到WebAPI的WebAPI请求。这需要返回状态代码为HttpStatusCode.Moved的HttpResponseMessage,以便将浏览器重定向到另一个URL。我的问题是这个目标URL必须是POST请求,带有POST参数。我该如何做到这一点? 到目前为止,我已经尝试过:

HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.Moved);
var json = new Dictionary<string, string>() { { "postparameter", postparameter } };
response.Content = new StringContent(json.ToString());
response.Headers.Location = new Uri(targetURL);
return response;

0 个答案:

没有答案
相关问题