I have actions in different controllers that need to check for a some condition before execution. If the condition is not met, I want the user be redirected to another page with instructions on what to do next (the instructions will include a link that the user must follow).
For example SendMessage() action is located in the Message controller:
public ActionResult SendMessage()
{
// check if user has enough credit
if (!hasEnoughCredit(currentUser))
{
// redirect to another page that says:
// "You do not have enough credit. Please go to LinkToAddCreditAction
// to add more credit."
}
// do the send message stuff here
}
I want to have a single generic action called ShowRequirements() located in Requirements controller.
In SendMessage() action, I would like to set the message that I want to show to the user and then forward the user to ShowRequirements() action. I just don't want the message to appear in the URL of the ShowRequirements action.
Is there any way to communicate this data to ShowRequirements() action?