在没有MVC的纯ASP.NET Web API服务中,我们仍然需要Global.asax中的AreaRegistration.RegisterAllAreas()吗? [英] Do we still need AreaRegistration.RegisterAllAreas() in Global.asax in pure ASP.NET Web API service without MVC

查看:287
本文介绍了在没有MVC的纯ASP.NET Web API服务中,我们仍然需要Global.asax中的AreaRegistration.RegisterAllAreas()吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试创建一个干净的ASP.NET Web API服务,并且尽可能不引用MVC程序集. 我关注了这个博客 http://www .codeproject.com/Articles/615805/Creating-a-Clean-Minimal-Footprint-ASP-NET-WebAPI 但是在Global.asax中使用这一行,我仍然必须导入System.Web.Mvc程序集.如果删除它,我的Web API服务会受到影响吗?我尝试在没有本地服务的地方运行我的服务,但没有遇到任何错误.

I'm trying to create a clean ASP.NET Web API service without referencing MVC assemblies if possible. I followed this blog http://www.codeproject.com/Articles/615805/Creating-a-Clean-Minimal-Footprint-ASP-NET-WebAPI but with this line in Global.asax I still have to import System.Web.Mvc assembly. Would there be an impact in my web api service if I removed it? I tried running my service in my local without it and I did not encounter any error.

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

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

}

推荐答案

如果您不使用MVC区域,则无需调用AreaRegistration.RegisterAllAreas()

If you're not using MVC areas then there should be no need to call AreaRegistration.RegisterAllAreas()

这篇关于在没有MVC的纯ASP.NET Web API服务中,我们仍然需要Global.asax中的AreaRegistration.RegisterAllAreas()吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆