|
1 | 1 | namespace Microsoft.Examples |
2 | 2 | { |
3 | 3 | using Microsoft.AspNetCore.Builder; |
4 | | - using Microsoft.AspNetCore.Hosting; |
5 | 4 | using Microsoft.AspNetCore.Mvc.ApiExplorer; |
6 | 5 | using Microsoft.Extensions.Configuration; |
7 | 6 | using Microsoft.Extensions.DependencyInjection; |
|
10 | 9 | using Swashbuckle.AspNetCore.SwaggerGen; |
11 | 10 | using System.IO; |
12 | 11 | using System.Reflection; |
13 | | - using static Microsoft.AspNetCore.Mvc.CompatibilityVersion; |
14 | 12 |
|
15 | 13 | /// <summary> |
16 | 14 | /// Represents the startup process for the application. |
@@ -38,9 +36,7 @@ public Startup( IConfiguration configuration ) |
38 | 36 | /// <param name="services">The collection of services to configure the application with.</param> |
39 | 37 | public void ConfigureServices( IServiceCollection services ) |
40 | 38 | { |
41 | | - // the sample application always uses the latest version, but you may want an explicit version such as Version_2_2 |
42 | | - // note: Endpoint Routing is enabled by default; however, if you need legacy style routing via IRouter, change it to false |
43 | | - services.AddMvc( options => options.EnableEndpointRouting = true ).SetCompatibilityVersion( Latest ); |
| 39 | + services.AddControllers(); |
44 | 40 | services.AddApiVersioning( |
45 | 41 | options => |
46 | 42 | { |
@@ -74,11 +70,11 @@ public void ConfigureServices( IServiceCollection services ) |
74 | 70 | /// Configures the application using the provided builder, hosting environment, and API version description provider. |
75 | 71 | /// </summary> |
76 | 72 | /// <param name="app">The current application builder.</param> |
77 | | - /// <param name="env">The current hosting environment.</param> |
78 | 73 | /// <param name="provider">The API version descriptor provider used to enumerate defined API versions.</param> |
79 | | - public void Configure( IApplicationBuilder app, IHostingEnvironment env, IApiVersionDescriptionProvider provider ) |
| 74 | + public void Configure( IApplicationBuilder app, IApiVersionDescriptionProvider provider ) |
80 | 75 | { |
81 | | - app.UseMvc(); |
| 76 | + app.UseRouting(); |
| 77 | + app.UseEndpoints( builder => builder.MapControllers() ); |
82 | 78 | app.UseSwagger(); |
83 | 79 | app.UseSwaggerUI( |
84 | 80 | options => |
|
0 commit comments