Пример #1
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddDbContext <ApplicationDbContext>(options =>
                                                         options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));

            services.AddIdentity <ApplicationUser, IdentityRole>()
            .AddEntityFrameworkStores <ApplicationDbContext>()
            .AddDefaultTokenProviders();

            // Add application services.
            services.AddTransient <IEmailSender, EmailSender>();
            LocalizationConfig.Configure(services);
            services.AddMvc()
            .AddDataAnnotationsLocalization()
            .AddViewLocalization(LanguageViewLocationExpanderFormat.Suffix);
        }
Пример #2
0
        public static void Register(HttpConfiguration config)
        {
            //var cors = new EnableCorsAttribute("*", "*", "*");
            //config.EnableCors(cors);

            MediaTypeFormattingConfig.Configure(config);
            RoutingConfig.Configure(config);
            IoCConfig.Configure(config);
            TracingConfig.Configure(config, IoCConfig.Container);
            LoggingConfig.Configure();
            ExceptionHandlingConfig.Configure(config);
            ValidationConfig.Configure(config);
            LocalizationConfig.Configure(config);

            //configure authentication
            config.MessageHandlers.Insert(0, new AuthenticationHandler());

            //for gzip compression use:
            // config.MessageHandlers.Insert(0, new ServerCompressionHandler(new GZipCompressor(), new DeflateCompressor()));
        }
Пример #3
0
        /// <summary>
        /// Configures the application using the provided builder, hosting environment, and logging factory.
        /// </summary>
        /// <param name="app">The current application builder.</param>
        /// <param name="env">The current hosting environment.</param>
        /// <param name="loggerFactory">The logging factory used for instrumentation.</param>
        /// <param name="provider">The API version descriptor provider used to enumerate defined API versions.</param>
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory, IApiVersionDescriptionProvider provider)
        {
            loggerFactory.AddConsole(this.Configuration.GetSection("Logging"));
            loggerFactory.AddFile(this.Configuration.GetSection("Logging").GetValue <string>("PathFormat"), isJson: true);

            if (env.IsDevelopment() || Program.IsLocal(env))
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseHsts();
            }

            // Custom Configuration
            LocalizationConfig.Configure(app);
            SwaggerConfig.Configure(app, provider);

            app.UseHttpsRedirection();
            app.UseMvc();
        }
Пример #4
0
        // 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.UseBrowserLink();
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseAuthentication();
            LocalizationConfig.Configure(app);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }