Skip to content

Instantly share code, notes, and snippets.

@joshka
Created October 18, 2010 12:44
Show Gist options
  • Save joshka/632146 to your computer and use it in GitHub Desktop.
Save joshka/632146 to your computer and use it in GitHub Desktop.
public class TestController : Controller
{
public ActionResult Index()
{
return View("Index").WithStatus("Some message");
}
}
public static class StatusResultExtensions
{
public static ActionResult WithStatus(this ActionResult result, string status)
{
return new StatusResult(result, status);
}
}
public class StatusResult : ActionResult
{
private readonly ActionResult _result;
private readonly string _status;
public StatusResult(ActionResult result, string status)
{
_result = result;
_status = status;
}
public override void ExecuteResult(ControllerContext context)
{
context.Controller.TempData["Status"] = _status;
_result.ExecuteResult(context);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment