ASP.NET Core MVC配置差別(3.0和2.X)

http://www.javashuo.com/article/p-xnequegc-x.htmlhtml

net core 2.x MVC配置app

        public void ConfigureServices(IServiceCollection services)
        { services.addMvc(); }

 

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,IConfiguration configurarion,IWelcome welcome)
        {
            if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseRouting(); app.UseStaticFiles(); app.UseMvc(routs => { routs.MapRoute("default", "{controller=Home}/{action=Index}/{id?}"); }); }

net core 3.x MVC配置ui

        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllersWithViews();
        }

 

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env,IConfiguration configurarion,IWelcome welcome)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }

            app.UseRouting();
            app.UseStaticFiles();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllerRoute("default", "{controller=Home}/{action=Index}/{id?}");
            });
        }
相關文章
相關標籤/搜索