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();
            }
            else
            {
                app.UseExceptionHandler(AllException);
            }

            app.UseIgnoreUrl("Views");

            app.UseResponseCompression();

            // 此部分为作者需要,你们可以直接删掉
            var staticfile = new StaticFileOptions();
            var provider   = new Microsoft.AspNetCore.StaticFiles.FileExtensionContentTypeProvider();

            provider.Mappings.Add(".php", "text/plain");//手动设置对应MIME
            provider.Mappings.Add(".aspx", "text/plain");
            staticfile.ContentTypeProvider = provider;
            //staticfile.OnPrepareResponse = (a) =>
            //{

            //};
            app.UseStaticFiles(staticfile);

            app.UseDiySession();

            app.UseAshx(routes =>
            {
                routes.MapApiRoute(
                    name: "Api",
                    areaName: "AdminCore.Api",
                    template: "Api/{controller=AdminServers}/{action}/{id?}");

                routes.MapApiRoute(
                    name: "Admin",
                    areaName: "AdminCore.WebUi",
                    template: "{controller=Admin}/{action=Index}/{id?}");
            });

            FacadeManage.UseSqlLog(loggerFactory); //注册相关SQL日志。

            Menu.Reload();                         //获取默认系统菜单

            TcpFrame.ConnectClient(loggerFactory);

            app.GetObject <UpLoad>().SetBasePath(env.WebRootPath);

            Api.AdminServers.StartBaseLog();
        }