WebApplication1/Startup.cs
/// <summary>
/// Configure the server's services.
/// </summary>
/// <remarks>This method gets called by the runtime.</remarks>
/// <param name="services">The default service collection of this web service </param>
Configure the server's services.
Configure the server ' s services .
public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
            services.AddSwaggerGen(c =>
            {
                c.SwaggerDoc("v1", new Info { Title = "Todo API", Version = "v1" });
                var xmlDocsPath = Path.Combine(
                    AppDomain.CurrentDomain.BaseDirectory,
                    string.Format(@"{0}.xml",
                    Assembly.GetExecutingAssembly().GetName().Name)
                );
                c.IncludeXmlComments(xmlDocsPath);
            });
            services.AddCors(builder =>
            {
                builder.AddPolicy("default", options =>
                {
                    options.AllowAnyHeader();
                    options.AllowAnyMethod();
                    options.AllowAnyOrigin();
                });
            });
        }
public void ConfigureServices ( IServiceCollection services ) { services . AddMvc ( ) . SetCompatibilityVersion ( CompatibilityVersion . Version_2_1 ) ; services . AddSwaggerGen ( c => { c . SwaggerDoc ( " " , new Info { Title = " " , Version = " " } ) ; var xmlDocsPath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , string . Format ( @"{0}.xml" , Assembly . GetExecutingAssembly ( ) . GetName ( ) . Name ) ) ; c . IncludeXmlComments ( xmlDocsPath ) ; } ) ; services . AddCors ( builder => { builder . AddPolicy ( " " , options => { options . AllowAnyHeader ( ) ; options . AllowAnyMethod ( ) ; options . AllowAnyOrigin ( ) ; } ) ; } ) ; }
Configure the server's services.
Configure the server ' s services .
// Define the version of MVC that we wish to use (this should match the current .net core version) // Add The Swagger Documentation Generator Service // Define an API with v1 // Tell Swagger to use the compiler generated XML documentation // {0} - The name of the current namespace / the exported XML file name // Add the CORS services so that we can access this API from external hosts // * Google CORS for more info * // Add a default policy
services
IServiceCollection
The default service collection of this web service
The default service collection of this web service
remarks
This method gets called by the runtime.
This method gets called by the runtime .