ASP.NET Core MVC配置差异(3.0和2.X)
程序员文章站
2022-07-02 12:22:38
https://www.cnblogs.com/lonelyxmas/p/10934388.html net core 2.x MVC配置 public void ConfigureServices(IServiceCollection services) { services.addMvc(); ......
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?}"); }); }
上一篇: Class文件结构全面解析(下)
下一篇: 24 道 shell 脚本面试题