Redirect to the same or different controller-view after a POST request

We can redirect the user to the same view (referrer view) or a different controller action by using the redirect method. If you want to maintain the flash messages set from the controller, you must use the return keyword. Otherwise, flash messages won’t work.