我正在使用以下技术:
以下是我的Global.asax.cs文件中MvcApplication的代码。
- asp.net mvc rc 2
- Ninject和ninject asp.net mvc扩展(http://github.com/enkari/ninject.web.mvc)
以下是我的Global.asax.cs文件中MvcApplication的代码。
public class MvcApplication : NinjectHttpApplication // System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Account", action = "Login", id = "" } // Parameter defaults
);
}
protected override void OnApplicationStarted()
{
AreaRegistration.RegisterAllAreas();
RegisterRoutes(RouteTable.Routes);
RegisterAllControllersIn(Assembly.GetExecutingAssembly());
}
protected override IKernel CreateKernel()
{
return new StandardKernel(new INinjectModule[] {
new ServiceModule(),
});
}
}