806
Views
5
Comments
Solved
How to redirect to an external URL from a server action?
Question

I have an exposed rest service in my application, and I am trying to handle a GET request, then based on it I have to redirect the user to another URL from the internet.

I have tried the server action "AddMetaHttpEquivTag" to force a HTML redirect like

<meta http-equiv="refresh" content="time; URL=new_url" /> 

but it didn't work.

Does anyone have an idea about how to solve this?

2018-10-29 08-31-03
João Marques
 
MVP
Solution

Hi Edgar,


You can add a header Location using AddHeader from HttpRequestHandler extension and then set the Status Code (using SetStatusCode also from HttpRequestHandler) to 308 for Permanently Moved or 307 for Temporarily Moved:



And then the SetStatusCode to 308:



Hope it helps.


Cheers,

João

UserImage.jpg
Edgar Fabiano

Worked perfectly like a charm!

Thanks a lot, João.

2025-03-19 01-45-51
Sandeep Kumar Kolli

Hi Joao, can you please attach a sample oml for the above solution if possible.

Thanks

Sandeep

UserImage.jpg
Rajesh Palaparthi

In my case its not takes place any redirection. con you attach sample working oml please


Thanks

Rajesh

2022-01-19 02-25-24
Trev

Same. No redirection takes place.  
In this instance, does the client side code need to handle to handle the 308 and redirect to the Location address in the response header?


Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.