简体   繁体   中英

Redirect to another site from WebAPI

The case in hand is as follows:

  1. User hits a control on a website, website calls an API.
  2. API does some logic, and shall then construct a post http request and redirect to another site.
  3. User should view the redirected site.

Alternative solution i guess is for the api to return an object that the website can use to redirect.

Your kind suggestions and ideas

You should take a look at the HTTP/1.1 Status Code Definitions . Specifically section 10.3 "Redirection 3xx". It describes the available status codes, and you should be able to find a suitable one.

Example: 303 See Other

Your API would create a response with status code 303 and add a "Location" header that contains the address of the site you redirect to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM