The most primitive way is to use the ViewBag
; so in the action you might do something like this:
ViewBag.Success = callToMethod();
and then in the view for the action, you can get at that like this:
@if (ViewBag.Success != null && (bool)ViewBag.Success)
{
// render something
}
else
{
// render something
}
There are of course other ways. It could be that you already have a view model for the view and you just need to add a boolean flag to the view model. If you did something like that, then instead of grabbing it off the ViewBag
, you might (and this depends on your @model
type) access it like this, Model.Success
, instead. And of course, if you added it to the view model, in the action you'd set the result of the method to the instance of the view model.