【发布时间】:2018-08-25 19:06:39
【问题描述】:
我有一个 ASP.NET Core Api,在控制器中有一个 Post 方法和一个调用它的 Angular 服务 直到今天,我使用路由器从角度内部进行导航,但我需要知道它是否可能以及如何从服务器重定向并在角度 Post 方法上处理这种情况,该方法将接收重定向响应而不是一些 JSON 对象。浏览器是否可以自行处理,或者我需要在收到响应后在调用中执行某些操作?
客户端和服务器运行在同一台服务器上
控制器
[HttpPost]
public ActionResult Post([FromBody]string myvalue)
{
// some operations here
string parameter = SomeFunctionReturningParameter(myvalue);
return new RedirectResult("/component2?param=" + parameter);
}
}
角度服务
public callRedirection(apiEnd:, body: any): Observable<any> {
return this.http.post(endPoint, body)
.map((response) => {
//how to handle redirect here
return response;
})
.catch(error => { console.log(error) });
}
有什么想法???
【问题讨论】:
标签: angular http asp.net-core url-redirection angular-services