Exemple #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, IApplicationLifetime appLifetime)
        {
            app.UseCoreContextProvider();

            if (env.IsDevelopment())
            {
                app.UseBrowserLink();
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            //使用授权
            app.UseAuthentication();
            // web socket
            app.Map("/ws", SocketHandler.Map);

            app.UseStaticFiles(new StaticFileOptions {
                //不能识别的文件,作为图片处理
                ServeUnknownFileTypes = true,
                DefaultContentType    = "image/png"
            });

            //demo
            //app.UseMiddleware<VoiceSchedulerJob>();

            //SEssion
            app.UseSession();
            //mvc路由
            app.UseMvc(routes =>
            {
                //针对Area

                routes.MapAreaRoute(
                    name: "SystemManage", areaName: "SystemManage",
                    template: "SystemManage/{controller=Home}/{action=Index}"
                    );

                routes.MapAreaRoute(
                    name: "SystemSecurity", areaName: "SystemSecurity",
                    template: "SystemSecurity/{controller=Home}/{action=Index}"
                    );

                routes.MapAreaRoute(
                    name: "SysComponent", areaName: "SysComponent",
                    template: "SysComponent/{controller=Controll}/{action=Index}"
                    , defaults: new string[] { "SkyMallCoreWeb.Areas.SysComponent.Controllers" }
                    );


                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}"
                    , defaults: new string[] { "SkyMallCoreWeb.Controllers" }
                    );
            });


            //程序停止调用函数
            appLifetime.ApplicationStopped.Register(() => { IOCContainer.Dispose(); });
        }