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?

mvp_badge
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

Worked perfectly like a charm!

Thanks a lot, João.

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

Thanks

Sandeep

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


Thanks

Rajesh

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