I've just completed watching the Scott Hanselman screencasts of the new MVC release (congrads on the fast update!) and have encountered an issue with the HandleUnknownAction. Here's how you can reproduce the issue:
1) Modify Global.asax.cs adding the following line
ControllerBuilder.Current.SetControllerFactory(typeof(Qubit.Controllers.InterceptingControllerFactory));
2) Create a new file (I followed Scott's example) titled 'InterceptingControllerFactory.cs' in the Controllers folder
public class InterceptingControllerFactory : DefaultControllerFactory
{
protected override IController GetControllerInstance(Type controllerType)
{
IController controller = base.GetControllerInstance(controllerType);
return new InterceptionController(controller);
}
}
3) Create a new file (again following Scott's example) titled 'InterceptionController.cs' in the Controllers folder
public class InterceptionController : Controller
{
private IController _controller;
public InterceptionController(IController interceptedController)
{
this._controller = interceptedController;
}
protected override void HandleUnknownAction(string actionName)
{
// Shouldn't this only execute for an unknown action?
// It is executed for even the default url of http://localhost:49327/
//throw new InvalidOperationException(String.Format("Sorry but we don't allow '{0}' actions.", actionName));
this._controller.Execute(this.ControllerContext);
}
}
My expectation is for the HandleUnknownAction method to only execute on a Missing Action method when in fact it executes for URLs such as the default empty URL which is still handled by the routing engine. Is my assumption incorrect or is this a bug?
Thanks!