在没有MVC的纯ASP.NET Web API服务中,我们是否还需要Global.asax中的AreaRegistration.RegisterAllAreas()

mas*_*pau 11 c# asp.net-mvc-4 asp.net-web-api

我试图创建一个干净的ASP.NET Web API服务,如果可能的话,不引用MVC程序集.我关注了这个博客http://www.codeproject.com/Articles/615805/Creating-a-Clean-Minimal-Footprint-ASP-NET-WebAPI 但是在Global.asax中使用这一行我还是要导入System.Web. Mvc组装.如果我将其删除,会对我的网络API服务产生影响吗?我尝试在没有它的情况下在我的本地运行我的服务,我没有遇到任何错误.

protected void Application_Start()
{
        //AreaRegistration.RegisterAllAreas(); do we still need this?

        WebApiConfig.Register(GlobalConfiguration.Configuration);  
        HandlerConfig.RegisterGlobalHandlers(GlobalConfiguration.Configuration);
        FilterConfig.RegisterGlobalFilters(GlobalConfiguration.Configuration.Filters);            

}
Run Code Online (Sandbox Code Playgroud)

chr*_*.00 19

如果你没有使用MVC区域,那么就没有必要打电话了 AreaRegistration.RegisterAllAreas()