NetCoreWebApi3.0-------MiniProfiler使用教程
参考博客:ASP.NET Core WebAPI中的分析工具MiniProfiler - LamondLu - 博客园 (cnblogs.com)
注意事项:
1.不要盲目copy别人的代码
var html = MiniProfiler.Current.RenderIncludes(HttpContext);
下面我加粗的 这一段代码 请使用这面的语句获取 (html的代码为官网自带的 可以自己去下载 ,也可以试试我的这一段代码)
<script async="async" id="mini-profiler" src="/profiler/includes.min.js?v=4.2.22+4563a9e1ab" data-version="4.2.22+4563a9e1ab" data-path="/profiler/" data-current-id="a0e888ed-9ea4-4c14-bfd1-cf3362d5942c" data-ids="a0e888ed-9ea4-4c14-bfd1-cf3362d5942c" data-position="Left" " data-scheme="Light" data-authorized="true" data-max-traces="15" data-toggle-shortcut="Alt+P" data-trivial-milliseconds="2.0" data-ignored-duplicate-execute-types="Open,OpenAsync,Close,CloseAsync"></script>
<!-- HTML for static distribution bundle build -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>%(DocumentTitle)</title>
<link rel="stylesheet" type="text/css" href="./swagger-ui.css">
<link rel="icon" type="image/png" href="./favicon-32x32.png" sizes="32x32" />
<link rel="icon" type="image/png" href="./favicon-16x16.png" sizes="16x16" />
<style> html {
box-sizing: border-box;
overflow: -moz-scrollbars-vertical;
overflow-y: scroll;
} *,
*:before,
*:after {
box-sizing: inherit;
} body {
margin: 0;
background: #fafafa;
}
</style>
%(HeadContent)
</head> <body>
<div id="swagger-ui"></div> <!-- Workaround for https://github.com/swagger-api/swagger-editor/issues/1371 -->
<script>
if (window.navigator.userAgent.indexOf("Edge") > -1) {
console.log("Removing native Edge fetch in favor of swagger-ui's polyfill")
window.fetch = undefined;
}
</script> <script src="./swagger-ui-bundle.js"></script>
<script src="./swagger-ui-standalone-preset.js"></script>
<script>
/* Source: https://gist.github.com/lamberta/3768814
* Parse a string function definition and return a function object. Does not use eval.
* @param {string} str
* @return {function}
*
* Example:
* var f = function (x, y) { return x * y; };
* var g = parseFunction(f.toString());
* g(33, 3); //=> 99
*/
function parseFunction(str) {
if (!str) return void (0); var fn_body_idx = str.indexOf('{'),
fn_body = str.substring(fn_body_idx + 1, str.lastIndexOf('}')),
fn_declare = str.substring(0, fn_body_idx),
fn_params = fn_declare.substring(fn_declare.indexOf('(') + 1, fn_declare.lastIndexOf(')')),
args = fn_params.split(','); args.push(fn_body); function Fn() {
return Function.apply(this, args);
}
Fn.prototype = Function.prototype; return new Fn();
} window.onload = function () {
var configObject = JSON.parse('%(ConfigObject)');
var oauthConfigObject = JSON.parse('%(OAuthConfigObject)'); // Workaround for https://github.com/swagger-api/swagger-ui/issues/5945
configObject.urls.forEach(function (item) {
if (item.url.startsWith("http") || item.url.startsWith("/")) return;
item.url = window.location.href.replace("index.html", item.url).split('#')[0];
}); // If validatorUrl is not explicitly provided, disable the feature by setting to null
if (!configObject.hasOwnProperty("validatorUrl"))
configObject.validatorUrl = null // If oauth2RedirectUrl isn't specified, use the built-in default
if (!configObject.hasOwnProperty("oauth2RedirectUrl"))
configObject.oauth2RedirectUrl = (new URL("oauth2-redirect.html", window.location.href)).href; // Apply mandatory parameters
configObject.dom_id = "#swagger-ui";
configObject.presets = [SwaggerUIBundle.presets.apis, SwaggerUIStandalonePreset];
configObject.layout = "StandaloneLayout"; // Parse and add interceptor functions
var interceptors = JSON.parse('%(Interceptors)');
if (interceptors.RequestInterceptorFunction)
configObject.requestInterceptor = parseFunction(interceptors.RequestInterceptorFunction);
if (interceptors.ResponseInterceptorFunction)
configObject.responseInterceptor = parseFunction(interceptors.ResponseInterceptorFunction); // Begin Swagger UI call region const ui = SwaggerUIBundle(configObject); ui.initOAuth(oauthConfigObject); // End Swagger UI call region window.ui = ui
}
</script>
</body>
</html>
2.中间件使用
请按照Swagger在前 使用 否则会产生垃圾日志,也就是 你进入Swagger就会产生耗时
#region Swagger app.UseSwagger();
app.UseSwaggerUI(c =>
{
c.SwaggerEndpoint("/swagger/v1/swagger.json", "ZeRunKangCore");
c.RoutePrefix = string.Empty;
c.IndexStream = () => GetType().GetTypeInfo().Assembly.GetManifestResourceStream("ZeRunK_Server.index.html"); }); #endregion Swagger #region MiniProfiler
//运行时间
app.UseMiniProfiler();
app.UseStaticFiles();
3.搭配aop使用 效果更佳
NetCoreWebApi3.0-------MiniProfiler使用教程的更多相关文章
- Solr 4.0 部署实例教程
Solr 4.0 部署实例教程 Solr 4.0的入门基础教程,先说一点部署之后肯定会有人用solrj,solr 4.0好像添加了不少东西,其中CommonsHttpSolrServer这个类改名为H ...
- Windows服务器安装配置PHP7.0环境图文教程
摘自http://www.111cn.net/phper/linux-php/109865.htm Windows服务器安装配置PHP7.0环境图文教程 www.111cn.net 更新:2016-0 ...
- [苏飞开发助手V1.0测试版]官方教程与升级报告
[苏飞开发助手V1.0测试版]官方教程与升级报告导读部分----------------------------------------------------------------- ...
- Omnet++ 4.0 入门实例教程
http://blog.sina.com.cn/s/blog_8a2bb17d01018npf.html 在网上找到的一个讲解omnet++的实例, 是4.0下面实现的. 我在4.2上试了试,可以用. ...
- CentOS 6.0 图文安装教程
CentOS 6.0下载地址:wget http://ftp.riken.jp/Linux/centos/6.0/isos/i386/CentOS-6.0-i386-bin-DVD.iso 下边就是安 ...
- MySql-8.0.12 安装教程
MySql-8.0.12 安装教程随笔https://www.cnblogs.com/CrazyDemo/p/9409995.html MySQL 安装https://m.runoob.com/mys ...
- Retrofit 2.0 使用详细教程
文章来自:https://blog.csdn.net/carson_ho/article/details/73732076 前言 在Andrroid开发中,网络请求十分常用 而在Android网络请求 ...
- 《开源网店系统iWebShop2.0模板开发教程》的说明
<开源网店系统iWebShop2.0模板开发教程>是网上广为流传的一个文档,有点问题. 其中的第4章: ========================================== ...
- [Android 编译(一)] Ubuntu 16.04 LTS 成功编译 Android 6.0 源码教程
本文转载自:[Android 编译(一)] Ubuntu 16.04 LTS 成功编译 Android 6.0 源码教程 1 前言 经过3天奋战,终于在Ubuntu 16.04上把Android 6. ...
- ECMAScript 6.0基础入门教程
ECMAScript 6.0基础入门教程 转:https://blog.csdn.net/hexinyu_1022/article/details/80778727 https://blog.csdn ...
随机推荐
- OpenMP 教程(一) 深入人剖析 OpenMP reduction 子句
OpenMP 教程(一) 深入人剖析 OpenMP reduction 子句 前言 在前面的教程OpenMP入门当中我们简要介绍了 OpenMP 的一些基础的使用方法,在本篇文章当中我们将从一些基础的 ...
- day15-Servlet04
Servlet04 12.ServletConfig 12.1ServletConfig基本介绍 ServletConfig类是为Servlet程序配置信息的类 Servlet对象和ServletCo ...
- 【题解】CF1715A Crossmarket
题面传送门 解决思路 首先,我们让 Megan 先走,因为他可以留下传送门.可以得知,不管怎么走,他到达终点所耗费的能量一定是 \(n+m-2\) . 然后,Stanley 走时就可以利用传送门.考虑 ...
- Go语言核心36讲37
你好,我是郝林,今天我们继续来分享并发安全字典sync.Map的内容. 我们在上一篇文章中谈到了,由于并发安全字典提供的方法涉及的键和值的类型都是interface{},所以我们在调用这些方法的时候, ...
- nydusd 源码理解(一)
" 尝试通过 nydus[1] 源码理解工作流程.可能由于代码变动导致和本文记录的内容有出入. 1. 环境准备 git clone https://github.com/dragonflyo ...
- 关于windows上开启远程桌面连接不上的问题解决
解决办法 启用远程桌面连接(计算机-属性-远程设置) 选择第二个:允许运行任意版本远程桌面 关闭防火墙(或者给远程桌面添加端口3389放行也可以) 创建用户以及密码 这里注意,一定要建立密码,只有账号 ...
- 【数据库】SQL-随机生成区间内数值、日期、字符串,mock数据
〇.概述 1.参考 2.其他 一.随机生成数值 1.随机生成函数random_int() -- 随机数生成函数,int版 CREATE OR REPLACE FUNCTION random_int( ...
- 最新 2022 年 Kubernetes 面试题高级面试题及附答案解析
题1:Kubernetes Service 都有哪些类型? 通过创建Service,可以为一组具有相同功能的容器应用提供一个统一的入口地址,并且将请求负载分发到后端的各个容器应用上.其主要类型有: C ...
- 10-排序6 Sort with Swap(0, i) (25point(s))
10-排序6 Sort with Swap(0, i) (25point(s)) Given any permutation of the numbers {0, 1, 2,..., N−1}, it ...
- rpm和yum仓库
一.rpm rpm从官网下,或者自研 外来的硬件设备连接到Linux上,必须挂载 rpm -qa(all) 显示当前系统中以 RPM 方式安装的所有软件列表 rpm -q 软件名 查询指定软件是否已安 ...