0

I figured it'd be easier to ask here, where I can post some code, than in the comments of his solution. To see his solution, go here.

EDIT: Some progress, but a new error. In my ErrorController class, I'm getting a NotImplementedException:

public ActionResult InvokeHttp404(HttpContextBase httpContext)
{
    IKernel kernal = new StandardKernel();
    IController errorController = kernal.Get<ErrorController>();
    var errorRoute = new RouteData();
    errorRoute.Values.Add("controller", "Error");
    errorRoute.Values.Add("action", "Http404");
    errorRoute.Values.Add("path", httpContext.Request.Url.OriginalString);
    errorController.Execute(new RequestContext(
         httpContext, errorRoute)); // <-- here

    return new EmptyResult();
}

Specifically, the exception message is:

The model item passed into the dictionary is of type 'HandiGamer.WebUI.Controllers.NotFoundViewModel', but this dictionary requires a model item of type 'System.String'.

I'm not sure which dictionary it's referring to, and MSDN has been less than helpful.

Community
  • 1
  • 1
Major Productions
  • 5,914
  • 13
  • 70
  • 149
  • Seems like your `errorController` instance is not working as expected for some reason. I'm not a Ninject guru so perhaps i can't help much here. – Matt Kocaj Apr 28 '11 at 01:13
  • That's okay... at least I have an idea of where to look. – Major Productions Apr 28 '11 at 01:16
  • 1
    StructureMap is really easy to get going. Maybe try swapping it in and getting everything working then slowly swapping back Ninject - this trial/error process may slowly identify the ugly head(source) of the problem. – Matt Kocaj Apr 28 '11 at 01:17
  • I may do that, if I can't figure it out. Thanks for your help. :-) – Major Productions Apr 28 '11 at 01:20
  • I would recommend you the [following solution](http://stackoverflow.com/questions/619895/how-can-i-properly-handle-404s-in-asp-net-mvc/620559#620559). – Darin Dimitrov Apr 28 '11 at 06:36

1 Answers1

0

Oh God, the problem was me being an idiot. I neglected to change my view, so it was still anticipating a simple string for its view model rather than a NotFoundViewModel. Since IController.Execute() was being called in the raw, it was throwing an exception due to the view's internal dictionary not being set to accept the view model.

@cottsak, thanks for all your help and patience.

Major Productions
  • 5,914
  • 13
  • 70
  • 149