Do I really need the App_Start contents in Ninject.MVC3?
Downloading the Ninject.MVC3 package from NuGet creates this App_Start folder with a simple class in it; Which doesn't even compile out of the box, I might add.
Browsing through it, it doesn't seem to have any spectacular... functionality... or any at all. I also do not find it in the SampleApplication
for Ninject.Web.Mvc
where the project itself comes from. (https://github.com/ninject/ninject.web.mvc/tree/master/mvc3/src/SampleApplication)
Can someone explain the purpose of this folder/class? Deleting them seems to have no effect on my project. Is there some mystical ninja reason why I开发者_如何转开发 need to keep them? (or even why they are being made in the first place?)
Updated documentation: https://github.com/ninject/ninject.web.mvc/wiki/Setting-up-an-MVC3-application
The latest version of Ninject.MVC3 creates a folder, named App_Start, in your project. This folder contains the NinjectMVC3.cs class, which is the bootstrapper code for the Ninject framework. It has two assembly attributes that are used to start and stop the NinjectMVC3 code. It is these attributes that cause the WebActivator framework to invoke the bootstrapper class methods and start up the Ninject framework. Installing NinjectMVC3 also adds assembly references for Microsoft.Web.Infrastructure, Ninject, NinjectMVC3, and WebActivator.
The NinjectMVC3 class contains the RegisterServices method where you would add code to bind your interfaces to their concrete implementations. This is the file that you would edit to configure your dependencies.
This required, and is the only requirement, for using Ninject with your MVC application to handle your dependencies. Other instructions on adding code to global.asax.cs should be ignored.
Same question here gives the short answer = "No". It's just a new convention which only makes sense for large web sites and even that is not sure.
http://weblogs.asp.net/pjohnson/archive/2012/09/07/mvc-4-and-the-app-start-folder.aspx
Personally I prefer to deal with all routing and filter overrides in the global application class, shifting all common stuff to a shared base class so it only contains web site specific code. I see no need for separate classes either.
The usual case with ASP.NET special folders is that they provide different security permissions. Does anyone know if this App_Start folder is necessary in a partial trust environment? i.e. with restricted web hosting, is this the only place where you are allow to call functions to change the way the site routes?
Sounds like somebody at MS is thinking about adding this as a additional layer of security in the future, if it is not already there. Until I see a real world benefit of this I would just delete it.
精彩评论