我一直對我的第一個MVC的Web應用程序,自啓動它,我一直gettign此郵件後自動從我的Application_errror法派在Global.asax中這個ninject控制器工廠錯誤是什麼意思?
這純粹是一個404的消息?它將如何生成?我沒有任何控制器命名的文字,我得的HomeController和AssistanceController ...
System.InvalidOperationException: The IControllerFactory 'FightTheFloods.Infrastructure.NinjectControllerFactory' did not return a controller for the name 'text'.
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
The IControllerFactory 'FightTheFloods.Infrastructure.NinjectControllerFactory' did not return a controller for the name 'text'.
at System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state)
at System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
這裏是我的控制器工廠代碼
public class NinjectControllerFactory : DefaultControllerFactory
{
private IKernel kernel = new StandardKernel(new FightTheFloodsServices());
protected override IController GetControllerInstance(System.Web.Routing.RequestContext requestContext, Type controllerType)
{
if (controllerType == null)
return null;
return (IController)kernel.Get(controllerType);
}
/// <summary>
/// Configuration for Ninject
/// </summary>
private class FightTheFloodsServices : NinjectModule
{
public override void Load()
{
Bind<IAssistanceManager>().To<AssistanceManager>();
Bind<IAssistanceAlerter>().To<AssistanceAlerter>();
Bind<ILocationHelper>().To<LocationHelper>();
Bind<IUsersRepository>().To<UsersRepository>().WithConstructorArgument("connectionString", ConfigurationManager.
ConnectionStrings[
"AppDb"].
ConnectionString);
Bind<IAssistanceRequestRepository>().To<AssistanceRequestRepository>().WithConstructorArgument(
"connectionString", ConfigurationManager.
ConnectionStrings[
"AppDb"].
ConnectionString);
}
}
}
我們需要查看自定義控制器工廠中的代碼(GetControllerInstance方法)以提供幫助。 – RPM1984 2011-01-13 07:52:13