void publisher_Begin_Render(object sender, MvcEventArgs e) { // 获取即将输出的内容 string output = e.ctx.utils.getCurrentOutputString(); // 修改输出的内容 output = output.Replace("#{pageElapsedMilliseconds}", WebStopwatch.Stop().ElapsedMilliseconds.ToString("0.0000")); // 将修改后的内容放回上下文 e.ctx.utils.setCurrentOutputString(output); }
private static String getTimeJs() { StringBuilder sb = new StringBuilder(); sb.Append("<script>var eleTime = document.getElementById('elapseTime');if( eleTime ) {"); sb.AppendFormat("eleTime.innerHTML='{0}';", (WebStopwatch.Stop().ElapsedMilliseconds / 1000.0).ToString("0.0000")); sb.Append("};"); sb.Append("var eleSql = document.getElementById('sqlQueries');if( eleSql ) {"); sb.AppendFormat("eleSql.innerHTML='{0}';", DbContext.getSqlCount()); sb.Append("}</script>"); return(sb.ToString()); }