Hi folks,
I've got StructureMap working fine on my machine. Everything works great ... until I request a resource that doesn't exist. Instead of a 404, i get a 500 error.
eg. http://localhost:6969/lkfhklsfhskdfksdf
Checking the net, i was told to fix my structuremap controller class. Did that and joy! i now get the -original default 404 yellow screen page-. Ok, that's better than my 500 error page.
BUT, i want it to go to my custom 404 page :( If i call a bad action on a legit controller, i get my custom 404 page.
In my global.asax i have my custom routes, then the default, then finally the 404 route:
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Post", action = "Index", id = "" } // Parameter defaults
);
// Invalid/Unknown route.
routes.MapRoute(
"404-ResourceNotFound",
"{*url}",
new { controller = "StaticContent", action = "ResourceNotFound" }
);
Here's my structuremap controller code:
public class StructureMapControllerFactory: DefaultControllerFactory {
protected override IController GetControllerInstance(Type controllerType) {
if (controllerType != null) {
return ObjectFactory.GetInstance(controllerType) as Controller;
return base.GetControllerInstance(controllerType);
}
}
Any ideas? is there some way i could somehow get the structure map controller factory to bubble back into the global.asax
routes list? or have i done something really bad and need to fix up some other stuff.
cheers!