示例#1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            //注册aotofac
            AutofacConfig.Register();

            //毙掉XML使api返回为json
            GlobalConfiguration.Configuration.Formatters.XmlFormatter.SupportedMediaTypes.Clear();
        }
示例#2
0
        public void Configuration(IAppBuilder app)
        {
            // Serve Swagger UI
            app.UseStaticFiles();

            var httpConfig = new HttpConfiguration();

            // setup webapi
            WebApiConfig.Register(httpConfig);

            // setup swagger
            SwaggerConfig.Register(httpConfig);

            // setup autofac
            AutofacConfig.Register(httpConfig);

            // register to owin
            app.UseWebApi(httpConfig);
        }