Problem Description: just configured the swagger, follow netcore2.2 api controller configuration continue to open in the browser, the result of the error. . .
Solution: Find route level, the reasons for a long time, to no avail, and finally the api page in the normal cross-domain set up, and it seems set about post cross removed, continue to find, turned out to be a problem due to the order of registration time
// . This Method Called by the gets the Use The Runtime the this Method to the HTTP Request The Configure Pipeline. Public void the Configure (App IApplicationBuilder, IWebHostEnvironment the env) { app.UseStaticFiles (); app.UseCookiePolicy (); app.UseRouting (); / / allow cross-domain position and must be put right, otherwise an error loading app.UseCors ( " the any " ); app.UseEndpoints (endpoints => endpoints.MapDefaultControllerRoute ()); // enable middleware services generated Swagger as JSON endpoint app. UseSwagger (); // enable middleware services to swagger-ui, designated Swagger JSON endpoint app.UseSwaggerUI(c => { c.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1"); }); var log = LogManager.GetLogger(repository.Name, typeof(Startup)); log.Info("Start Runing"); }
Set Loading UseRouting cross-domain must be placed intermediate and UseEndpoints
Reference Links: https://www.cnblogs.com/puzi0315/p/12197612.html