Esempio n. 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, IHostingEnvironment env)
        {
            app.UseCors("any");
            app.UseStaticFiles();
            app.UseAuthentication();

            if (env.IsDevelopment())
            {
                //app.UseDeveloperExceptionPage();
            }
            app.UseStatusCodePages();
            app.UseJimuSwagger();

            // jimu client

            Jimu.IApplication host;
#if DEBUG
            if (string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SERVICE_GROUPS")))
            {
                host = new ApplicationClientBuilder(new ContainerBuilder(), "JimuAppClientSettings.local").Build();
            }
            else
            {
                host = new ApplicationClientBuilder(new ContainerBuilder()).Build();
            }
#else
            host = new ApplicationClientBuilder(new ContainerBuilder()).Build();
#endif

            app.UseJimu(host);
            host.Run();
        }
Esempio n. 2
0
        public void Configure
            (Microsoft.AspNetCore.Builder.IApplicationBuilder app,
            Microsoft.AspNetCore.Hosting.IWebHostEnvironment env)
        {
            app.UseHttpsRedirection();

            app.UseRouting();

            // Global cors policy
            app.UseCors(current => current
                        .AllowAnyOrigin()
                        .AllowAnyMethod()
                        .AllowAnyHeader());

            // Custom JWT auth middleware
            app.UseMiddleware <Infrastructure.Middlewares.JwtMiddleware>();

            // Swagger middleware
            app.UseSwagger();
            app.UseSwaggerUI(c =>
            {
                c.SwaggerEndpoint("/swagger/v1/swagger.json", "v1");
            });

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Esempio n. 3
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure
            (Microsoft.AspNetCore.Builder.IApplicationBuilder app,
            Microsoft.AspNetCore.Hosting.IHostingEnvironment env,
            Microsoft.Extensions.Logging.ILoggerFactory loggerFactory)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug(minLevel: LogLevel.Trace);

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            // **************************************************
            // Note:
            // نکته مهم آن است که محل نوشتن دستور ذیل بسیار
            // اهمیت دارد، اگر بعد از دستور بعدی نوشته شود، عمل نمی‌کند
            // Note: For all Actions of Controllers
            app.UseCors("AllowSpecificOrigin");
            // **************************************************

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{culture=fa-IR}/{controller=Home}/{action=Index}/{id?}");
            });
        }
Esempio n. 4
0
        public void Configure
            (Microsoft.AspNetCore.Builder.IApplicationBuilder app,
            Microsoft.AspNetCore.Hosting.IWebHostEnvironment env)
        {
            //if (env.IsDevelopment())
            //{
            //	app.UseDeveloperExceptionPage();
            //}
            //else
            //{
            //	app.UseExceptionHandler("/Error");
            //	// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            //	app.UseHsts();
            //}

            //app.UseHttpsRedirection();

            app.UseCors(policyName: AdminCorsPolicy);

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });
        }
Esempio n. 5
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(Microsoft.AspNetCore.Builder.IApplicationBuilder app, IHostingEnvironment env, DataInitializer initializer)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
                app.UseHsts();
            }

            app.UseAuthentication();


            app.UseCors("AllowAllOrigins");


            app.UseHttpsRedirection();
            app.UseMvc();

            app.UseSwaggerUi3();

            app.UseSwagger();


            initializer.InitializeData().Wait();
        }
Esempio n. 6
0
 public void Configure(IApplicationBuilder app)
 {
     app.UseCors("CorsPolicy");
     app.UseOwin(x => x.UseNancy(opt => opt.Bootstrapper = new DefaultNancyBootstrapper()));
     app.UseDefaultFiles();
     app.UseStaticFiles();
 }
Esempio n. 7
0
        public static Microsoft.AspNetCore.Builder.IApplicationBuilder UseJimu(this Microsoft.AspNetCore.Builder.IApplicationBuilder app, IApplication host)
        {
            Console.WriteLine();
            app.UseMiddleware <JimuHttpStatusCodeExceptionMiddleware>();
            app.UseCors(builder =>
            {
                builder.AllowAnyOrigin().AllowAnyHeader().AllowAnyMethod();
            });

            var httpContextAccessor = app.ApplicationServices.GetRequiredService <IHttpContextAccessor>();

            JimuHttpContext.Configure(httpContextAccessor);
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller}/{action}");
                routes.MapRoute(
                    name: "defaultApi",
                    template: "api/{controller}/{action}");
                routes.MapRoute(
                    "swagger",
                    "swagger/{*path}"
                    );
                routes.MapRoute(
                    "JimuPath",
                    "{*path:regex(^(?!swagger))}",
                    new { controller = "JimuServices", action = "JimuPath" });
            });

            JimuClient.Host = host;
            return(app);
        }