// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } #region AutoMapper配置项 AutoMapperStartup.Register();//加载AutoMapper配置项 #endregion //使用跨域 app.UseCors("AllowAllOrigin"); // Enable middleware to serve generated Swagger as a JSON endpoint. app.UseSwagger(); // Enable middleware to serve swagger-ui (HTML, JS, CSS etc.), specifying the Swagger JSON endpoint. app.UseSwaggerUI(i => { i.SwaggerEndpoint("/swagger/v1/swagger.json", "CoreSolution API V1"); i.ShowExtensions(); }); app.UseMvc(); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); AutoMapperStartup.Map(); BundleConfig.RegisterBundles(BundleTable.Bundles); }
protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); GlobalConfiguration.Configure(WebApiConfig.Register); RouteConfig.RegisterRoutes(RouteTable.Routes); BundleConfig.RegisterBundles(BundleTable.Bundles); AutoMapperStartup.InitializeMapper(); GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = ReferenceLoopHandling.Ignore; }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } else { app.UseExceptionHandler("/Home/Error"); } app.UseStaticFiles(new StaticFileOptions { ContentTypeProvider = new FileExtensionContentTypeProvider { Mappings = { new KeyValuePair <string, string>(".moc", ""), new KeyValuePair <string, string>(".mtn", "") } } }); app.UseCookiePolicy(); AutoMapperStartup.Register();//加载AutoMapper配置项 app.UseAuthentication(); app.UseSignalR(routes => { routes.MapHub <ChatHub>("/chatHub"); }); app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller=Home}/{action=Index}/{id?}"); routes.MapRoute( name: "live2d", template: "{controller}", defaults: "live2d/model.moc" ); }); }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IServiceProvider serviceProvider, IncidentContext incidentContext) { LoggingStartup.AddLogging(env, loggerFactory, serviceProvider, _configuration); app.AddMiddleware(env, _configuration); AutoMapperStartup.InitializeAutomapper(); if (_env.IsDevelopment()) { SeedType seedType = _configuration["seedDataType"] == "manyEvents" ? SeedType.ManyEvents : SeedType.Basic; SeedData.Add(incidentContext, seedType); } }
// Configure is called after ConfigureServices is called. public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerfactory) { // Configure the HTTP request pipeline. // Add the console logger. loggerfactory.AddConsole(); // Add the following to the request pipeline only in development environment. if (string.Equals(env.EnvironmentName, "Development", StringComparison.OrdinalIgnoreCase)) { app.UseBrowserLink(); app.UseErrorPage(ErrorPageOptions.ShowAll); app.UseDatabaseErrorPage(DatabaseErrorPageOptions.ShowAll); } else { // Add Error handling middleware which catches all application specific errors and // send the request to the following path or controller action. app.UseErrorHandler("/Home/Error"); } // Add static files to the request pipeline. app.UseStaticFiles(); // Add cookie-based authentication to the request pipeline. app.UseIdentity(); // Add MVC to the request pipeline. app.UseMvc(routes => { routes.MapRoute( name: "default", template: "{controller}/{action}/{id?}", defaults: new { controller = "Products", action = "Index" }); // Uncomment the following line to add a route for porting Web API 2 controllers. // routes.MapWebApiRoute("DefaultApi", "api/{controller}/{id?}"); }); // setup automapper AutoMapperStartup.RegisterMaps(); }
public void Configuration(IAppBuilder app) { NinjectHttpContainer.RegisterModules(NinjectHttpModules.Modules); ApplicationUserManager.SetDataProtectionProvider(app.GetDataProtectionProvider()); // Configure the db context, user manager and signin manager to use a single instance per request app.CreatePerOwinContext(() => new DataAccessContext()); app.CreatePerOwinContext(() => { var context = new DataAccessContext(); var userStore = new UserStore <User, Role, Guid, UserLogin, UserRole, Claim>(context); return(new ApplicationUserManager(userStore)); }); //Authentication configuration var authConfig = NinjectHttpContainer.Resolve <AuthenticationConfiguration>(); authConfig.Config(accessTokenExpireMinutes: 120); authConfig.ConfigureAuth(app); var config = new HttpConfiguration(); ////WebApi configuration WebApiConfig.Register(config); app.UseCors(Microsoft.Owin.Cors.CorsOptions.AllowAll); // NInject config app.UseNinjectMiddleware(NinjectHttpContainer.GetKernel); app.UseNinjectWebApi(config); //Auto Maper AutoMapperStartup.Register(NinjectHttpContainer.GetKernel().GetService); //Logger ApplicationLogger.Logger.Configure(); config.MessageHandlers.Add(NinjectHttpContainer.Resolve <DelegatingLogFilter>()); config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver(); config.Formatters.JsonFormatter.UseDataContractJsonSerializer = false; }
public void ConfigureAutomapper() => AutoMapperStartup.InitializeAutomapper();