Monday, June 20, 2016

You can't use Url.Action at a Controller's constructor, but it will work a bit farther downstream in the life cycle.

An Action isn't the only place this is legit, however there are places where Url.Action will break the code too. The following is fine:

protected override void OnActionExecuting(ActionExecutingContext ctx)
{
   var foo = Url.Action("Index", "Whatever");

No comments:

Post a Comment