Example #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            loggerFactory.AddSerilog();

            DefaultFilesOptions options = new DefaultFilesOptions();

            options.DefaultFileNames.Clear();
            options.DefaultFileNames.Add("category.html");
            app.UseDefaultFiles(options);
            //app.UseHttpsRedirection();
            app.UseStaticFiles();

            //app.Use(async (context, next) => {
            //	// Ignore requests that don't point to static files.
            //	if (!context.Request.Path.Value.Contains("edit"))
            //	{
            //		await next();
            //		return;
            //	}



            //	///Don't return a 401 response if the user is already authenticated.
            //	bool canSeeThePage = context.Request.Cookies["user_Lognstatus"] == null;
            //	if (canSeeThePage)
            //	{
            //		context.Response.Redirect("/cms");
            //	}

            //	await next();
            //	return;
            //	// Stop processing the request and trigger a challenge.
            //	///await context.Authentication.ChallengeAsync("Cookies");
            //});

            //app.UseStaticFiles(new StaticFileOptions()
            //{
            //	FileProvider = new PhysicalFileProvider(Path.Combine(Directory.GetCurrentDirectory(), "wwwroot")),
            //	RequestPath = new PathString("/staticfiles")
            //});

            app.UseFileServer(enableDirectoryBrowsing: false);
            app.UseCors(
                options => options.WithOrigins("*").AllowAnyMethod().AllowAnyHeader()
                );

            app.UseSession();

            CMS.AppHttpContext.Services      = app.ApplicationServices;
            CMS.AppHttpContext.Configuration = Configuration;

            app.UseRouting();

            app.UseAuthentication();

            app.UseAuthorization();



            app.UseResponseCompression();

            app.UseEndpoints(endpoints =>
            {
                //endpoints.MapControllers();
                endpoints.MapControllerRoute("default", "cms3/{controller=Login}/{action=Index}/{id?}");
            });
            // app.UseElmah();

            //app.Run(async (context) =>
            //{
            //	await context.Response.WriteAsync("Hello World!");
            //	int[] numbers = new int[5];
            //	await context.Response.WriteAsync(numbers[6].ToString());
            //});
        }