2013-08-23 17 views
6

我想在不引用MVC程序集的情况下创建干净的ASP.NET Web API服务(如果可能)。 我跟着这个博客http://www.codeproject.com/Articles/615805/Creating-a-Clean-Minimal-Footprint-ASP-NET-WebAPI 但在Global.asax中的这一行我仍然需要导入System.Web.Mvc程序集。如果我删除它,会在我的web api服务中产生影响吗?我尝试在没有它的地方运行我的服务,并且没有遇到任何错误。我们是否仍然需要Global.asax中的AreaRegistration.RegisterAllAreas()在纯ASP.NET Web API服务中不使用MVC

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

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

} 
+1

。 – Nilesh

回答

14

如果你不使用MVC领域话,应该没有必要。如果你不使用,不需要注册区调用AreaRegistration.RegisterAllAreas()

+0

谢谢!谢谢! – masterlopau

相关问题