码迷,mamicode.com
首页 > Web开发 > 详细

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

时间:2019-11-26 13:30:13      阅读:81      评论:0      收藏:0      [点我收藏+]

标签:with   eve   bsp   ref   app   erro   core   index   apc   

https://www.cnblogs.com/lonelyxmas/p/10934388.html

net core 2.x MVC配置

        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配置

        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?}");
            });
        }

 

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

标签:with   eve   bsp   ref   app   erro   core   index   apc   

原文地址:https://www.cnblogs.com/CelonY/p/11934653.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!