NetCore WebApi 应用事项,验证,授权,数据库Orm(EFCoreXPO等)

Posted hopesun

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了NetCore WebApi 应用事项,验证,授权,数据库Orm(EFCoreXPO等)相关的知识,希望对你有一定的参考价值。

1、首先参考:我的第一个netcore2.2 api项目搭建(一)   https://www.cnblogs.com/sy-ds/p/10832504.html

      启用身份验证 Startup 中增加     app.UseAuthentication();

 

 

 

二、使用 Swagger 的过程:

1、nuget搜索:Swashbuckle.AspNetCore,安装 Swagger 工具 Nuget包。

2、在startup 的 ConfigureServices  注册swagger

            services.AddSwaggerGen(options =>
            
                options.SwaggerDoc("v1", new Info
                
                    //Version = "v1",
                    Title = "MyFirst API",//" API",
                );

                // Set the comments path for the Swagger JSON and UI.
                var xmlFile = $"Assembly.GetExecutingAssembly().GetName().Name.xml";
                var xmlPath = Path.Combine(AppContext.BaseDirectory, xmlFile);
                options.IncludeXmlComments(xmlPath, true);
                xmlPath = Path.Combine(AppContext.BaseDirectory, "JH.OPEMR.Model.xml");
                options.IncludeXmlComments(xmlPath, true);
            );
3、在Configure中启用swagger
            app.UseSwagger();
            // Enable middleware to serve swagger-ui (html, JS, CSS, etc.), specifying the Swagger JSON endpoint.
            app.UseSwaggerUI(options =>
            
                options.SwaggerEndpoint("/swagger/v1/swagger.json", "My API V1");
            );

 



以上是关于NetCore WebApi 应用事项,验证,授权,数据库Orm(EFCoreXPO等)的主要内容,如果未能解决你的问题,请参考以下文章