Hello.
I am creating an app on ReactiveWeb.
I want to set the HTTP status code on the screen to "404".
I tried to set "Set Status Code" to "On Initialize" and "On Ready", but it is still "200".
What should I do if I want to optionally change the HTTP status code?
I am happy to teach you.
Akari Ukai wrote:
check if this article can help you: https://www.outsystems.com/blog/posts/handling-http-status-codes-consuming-rest/
Carlos Lessa wrote:
Thank you for the answer.But it has not been resolved.I don't use web services.I just want to change the HTTP status code on the screen.
Thank you for the answer
I don't use web servicesI just want to change the HTTP status code on the screen
Can you give us more context of what are you trying to do? are you trying to redirect the user to a screen 404?
Thanks for the question, CarlosRedirect to the error screen you created,I want to set the HTTP status code of that screen to "404".Normally it is "200", but I want to set it to "404".
Hi Akari,
Let me ask you some questions first.
Please give us some more background.
Regards,
Nordin
Nordin Ahdi wrote:
Thanks for the question, Nordin· What are you trying to achieve?Here's what I want to do.(1) Write a condition with a client action on a screen and divide the branch into A screen and B screen(2) In case of B screen, I want to set HTTP status code to "404"(Screen B is an error screen created by myself.)· Why would you want to set the HTTP status code of a page request to 404? Since it is an error screen created by myself, it is usually "200".However, I want the user to recognize it as "404".· Why not just redirecting the user to some page (which can pose as a 404 page)?In the above example, it redirects to screen B.How about that.I'm waiting for an answer.
Hi Akari Ukai,
HTTP Status 404 is not for the users to see, it's for the browsers and/or web servers to handle and display a meaningful page that tells the users the resource they requested for could not be found.
Typically, in your applications you don't want to leave that sort of page in the hands of the user's browser nor the web server's default page, as they will completely break the user experience (a specialised "404" page within your applications would make a lot more sense, one that the users get redirected to when you raise a custom user exception, for instance?... you could add the handling of that custom user exception to the Global Exception Handler and it would apply *everywhere* in your module where you raise the exception.
That being said, it is possible to manipulate the current Request/Response using the HTTPRequestHandler extension (comes builtin as part of the platform) and its SetStatusCode action.
But setting the HTTP Status Code to 404 means that whatever is the screen you are returning, it will not be rendered by the browser (as those only render Responses with Status Code of 200) - either the web server or the browser will decide what to display.
Hope this helps.
Jorge Martins wrote:
Thank you for the answer.I will review the method.