假设我在ASP.NET Web API控制器中具有以下方法:
public HttpResponseMessage Get(string code1, string code2)
{
var response = new HttpResponseMessage(HttpStatusCode.Redirect);
response.Headers.Location = new Uri("/", UriKind.Relative);
return response;
}
我想接受传入的代码1和代码2的值,并将它们提供给MVC控制器(基于上面的重定向,我们假设它是HomeController)。做这个的最好方式是什么?
一些注意事项:
谢谢!
更新:这是最终代码和方法的外观。
public async Task<HttpResponseMessage> Get(string display, string code)
{
var auth = new AuthenticationClient();
await auth.WebServer(_consumerKey, _consumerSecret, _callbackUrl, code);
var url = string.Format("/?token={0}&api={1}&instance_url={2}", auth.AccessToken, auth.ApiVersion,
auth.InstanceUrl);
var response = new HttpResponseMessage(HttpStatusCode.Redirect);
response.Headers.Location = new Uri(url, UriKind.Relative);
return response;
}
除了使用查询字符串参数外,不确定是否还有其他选择。路径参数实际上没有多大意义,因为没有带有身份验证令牌的自然层次结构。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句