Marwan Tushyeh
Marwan Tushyeh

Reputation: 1525

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

Upvotes: 0

Views: 1287

Answers (1)

Dietz
Dietz

Reputation: 578

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.

Upvotes: 1

Related Questions