Exemple #1
0
 public static bool WebHostStart()
 {
     try
     {
         GlobalConfiguration.Configure(config => WebApiConfig.Register(config));
         GlobalConfiguration.Configure(config => AutofacConfig.Register(config, true));
         GlobalConfiguration.Configure(config => SwaggerConfig.Register(config, true));
         MapperConfig.Initial();
         return(true);
     }
     catch (Exception ex)
     {
         Logger.Info($"服务启动失败:{ex}");
         return(false);
     }
 }
Exemple #2
0
        public void Configuration(IAppBuilder app)
        {
            Logger.Info("启动配置!");
            HttpConfiguration config = new HttpConfiguration();

            //跨域配置
            //app.UseCors(CorsOptions.AllowAll);

            WebApiConfig.Register(config);
            AutofacConfig.Register(config);
            SwaggerConfig.Register(config);

            app.UseWebApi(config);
            app.MapSignalR();

            MapperConfig.Initial();
        }