已经配置完成了
HttpReports 是 .Net Core 下的一个Web项目, 适用于WebAPI,Ocelot网关应用,MVC项目,非常适合针对微处事应用使用,通过中间件的形式集成到您的项目中,可以让开发人员快速的搭建出一个 数据统计,分析,图表,监控 一体化的 Web站点。
主要包罗HttpReports 中间件 和 HttpReports.Web的MVC项目;
项目地点:
HttpReports: https://github.com/SpringLeee/HttpReports
HttpReports.Web: https://github.com/SpringLeee/HttpReports
在线预览: :8801 账号 admin 暗码 123456
撑持项目类型?? 单个WebAPI应用
?? 多个独立WebAPI应用
?? Ocelot 网关应用
?? 单个MVC项目
?? 多个MVC项目
Nuget 包安置 HttpReports, 打开Startup.cs, 改削 ConfigureServices(IServiceCollection services) 要领,添加以下代码,放在 services.AddMvc() 之前都可以。
选择您的应用类型:
?? 单个WebAPI应用 或者 使用Ocelot网关的应用
改削 ConfigureServices 要领 ,
public void ConfigureServices(IServiceCollection services) { // 添加HttpReports中间件 services.AddHttpReportsMiddleware(WebType.API, DBType.SqlServer); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }?? ** 多个独立的WebAPI应用 **
假设有一个 授权(Auth)API应用,和一个付出(Pay)API应用,并且没有使用网关,需要分袂在两个项目的Startup.cs文件的 ConfigureServices 要领中分袂添加以下代码:
授权API应用(Auth) services.AddHttpReportsMiddleware(WebType.API, DBType.SqlServer,"Auth"); 付出Pay应用(Pay) services.AddHttpReportsMiddleware(WebType.API, DBType.SqlServer,"Pay");?? 单个MVC应用
public void ConfigureServices(IServiceCollection services) { // 添加HttpReports中间件 services.AddHttpReportsMiddleware(WebType.MVC, DBType.SqlServer); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2); }?? 多个MVC应用
假设有一个 电商(Mall)应用,和一个付出(Pay)应用,需要分袂在两个项目的Startup.cs文件的 ConfigureServices 要领中分袂添加以下代码:
电商MVC应用 (Mall) services.AddHttpReportsMiddleware(WebType.MVC, DBType.SqlServer,"Mall"); 付出MVC应用 (Pay) services.AddHttpReportsMiddleware(WebType.MVC, DBType.SqlServer,"Pay");?? 切换数据库
使用MySql数据库
services.AddHttpReportsMiddleware(WebType.API, DBType.MySql);使用SqlServer数据库
services.AddHttpReportsMiddleware(WebType.API, DBType.SqlServer); 2.使用 HttpReports 中间件改削 StartUp.cs 的 Configure 要领
.Net Core 2.2
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { //使用HttpReports app.UseHttpReportsMiddleware(); app.UseMvc(); }必需要放在 UseMVC() 要领和其他中间件的前边,否则不生效。
.Net Core 3.0 和以上版本
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { //使用HttpReports app.UseHttpReportsMiddleware(); app.UseRouting(); app.UseAuthorization(); app.UseEndpoints(endpoints => { endpoints.MapControllers(); }); }必需要放在 UseEndpoints() 要领和其他中间件的前边,否则不生效。
3. appsettings.json 配置连接字符串打开 appsetting.json, 添加数据库连接字符串, 这个处所第一次措施会自动创建数据库和表, 固然也可以手动创建数据库
"ConnectionStrings": { "HttpReports": "Max Pool Size = 512;server=.;uid=sa;pwd=123456;database=HttpReports;" } 4. 运行Web应用到这一步,已经配置完成了, 直接运行Web应用,如果中间有报错的话,可能是因为数据库的连接问题,请查抄后再重试,如果没有报错的话,,打开数据库 [HttpReports].[dbo].[RequestInfo], 如果能看到有数据记录,就说明 HttpReports 中间件的部分配置完成了,数据有了,下边开始配置 HttpReportsWeb 站点。
HttpReports.Web 部分github源码:https://github.com/SpringLeee/HttpReportsWeb
这里供给 core2.2 和 3.0 的颁布版本下载:
Core 2.2 颁布版本: https://files.cnblogs.com/files/myshowtime/HttpReports2.2.zip
Core 3.0 颁布版本:https://files.cnblogs.com/files/myshowtime/HttpReports3.0.zip
温馨提示: 本文由Jm博客推荐,转载请保留链接: https://www.jmwww.net/file/web/31386.html