当前位置: 首页 > news >正文

莱芜网站制作如何对现有的网站改版

莱芜网站制作,如何对现有的网站改版,网络宣传平台,轻淘客 轻网站怎么做背景MVC MiniProfiler是Stack Overflow团队设计的一款对ASP.NET MVC的性能分析的小程序。可以对一个页面本身#xff0c;及该页面通过直接引用、Ajax、Iframe形式访问的其它页面进行监控,监控内容包括数据库内容#xff0c;并可以显示数据库访问的SQL#xff08;支持EF、EF … 背景MVC MiniProfiler是Stack Overflow团队设计的一款对ASP.NET MVC的性能分析的小程序。可以对一个页面本身及该页面通过直接引用、Ajax、Iframe形式访问的其它页面进行监控,监控内容包括数据库内容并可以显示数据库访问的SQL支持EF、EF CodeFirst等 。并且以很友好的方式展现在页面上。该Profiler的一个特别有用的功能是它与数据库框架的集成。除了.NET原生的 DbConnection类profiler还内置了对实体框架Entity Framework以及LINQ to SQL的支持。任何执行的Step都会包括当时查询的次数和所花费的时间。为了检测常见的错误如N1反模式profiler将检测仅有参数值存在差 异的多个查询。MiniProfiler是以Apache License V2.0协议发布的你可以在NuGet找到。配置及使用可以看这里http://code.google.com/p/mvc-mini-profiler概述在WebApi中对其性能进行分析监测是很有必要的。而悲剧的是MVC项目中可以使用的MiniProfiler或Glimpse等这些都不支持WebApi项目而且WebApi项目通常也没有界面不能进行性能分析的交互。在这篇文章中我们就来一步步实现为WebApi项目集成Miniprofiler。集成后我们可以监控EF执行效率执行语句页面执行时间等这些结果将以很友好的方式显示在界面上。问题本质上集成Miniprofiler可以分解为三个问题怎样监测一个WebApi项目的性能。将性能分析监测信息从后端发送到UI。在UI显示分析监测结果。实现方式首先安装Miniprofiler,MiniProfiler.EF6在Global.asax  加入using BQoolCommon.Helpers.Model; using Elmah; using ResearchManager.Web.App_Start; using System; using System.Configuration; using System.Web; using System.Web.Mvc; using System.Web.Routing; using StackExchange.Profiling; using StackExchange.Profiling.Mvc; using StackExchange.Profiling.EntityFramework6; using System.Web.Optimization; using NLog; using ResearchManager.Models.ValidateAttribute;namespace ResearchManager.Web {public class MvcApplication : HttpApplication{protected void Application_Start(){AreaRegistration.RegisterAllAreas();FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);RouteConfig.RegisterRoutes(RouteTable.Routes);BundleConfig.RegisterBundles(BundleTable.Bundles);//Remove Header X-AspNetMvc-VersionMvcHandler.DisableMvcResponseHeader true;AutofacConfig.Bootstrapper();//在 Controller 之前對 Model 做處理(字串 Trim)ModelBinders.Binders.DefaultBinder new BQoolModelBinder();//註冊自訂的 Validation (複寫預設的錯誤訊息)CustomerValidation.RegisterCustomerValidation();DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(CustomizedRequired), typeof(RequiredAttributeAdapter));DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(CustomizedStringLength), typeof(StringLengthAttributeAdapter));#region 测试//if (bool.Parse(ConfigurationManager.AppSettings[MiniProfiler] ?? false))//{MiniProfiler.Configure(new MiniProfilerOptions{RouteBasePath ~/profiler,PopupRenderPosition RenderPosition.Right, // defaults to leftPopupMaxTracesToShow 10, // defaults to 15ResultsAuthorize request request.IsLocal,ResultsListAuthorize request {return true; // all requests are legit in this example},// Stack trace settingsStackMaxLength 256, // default is 120 charactersTrackConnectionOpenClose true}.ExcludeType(SessionFactory) // Ignore any class with the name of SessionFactory).ExcludeAssembly(NHibernate) // Ignore any assembly named NHibernate.ExcludeMethod(Flush) // Ignore any method with the name of Flush.AddViewProfiling() // Add MVC view profiling (you want this));MiniProfilerEF6.Initialize();//}#endregion 测试}protected void Application_BeginRequest(Object source, EventArgs e){BundleTable.EnableOptimizations false;#region 测试MiniProfiler.StartNew();#endregion 测试}protected void Application_EndRequest(){#region 测试//MiniProfiler.Current?.Stop(); // Be sure to stop the profiler!#endregion 测试}#region Elmahprivate static readonly string _exceptionMsg A potentially dangerous Request.Path value was detected from the client;protected void Application_Error(object sender, EventArgs e){Exception ex Server.GetLastError();Logger nlogger LogManager.GetCurrentClassLogger();nlogger.Error(ex);if (BQoolCommon.Helpers.Setting.CommonSetting.IsProd()){if (e is ExceptionFilterEventArgs exceptionFilter){if (exceptionFilter.Exception is HttpException httpException httpException.Message.StartsWith(_exceptionMsg)){Response.Redirect(/);}}Response.Clear();Server.ClearError();Response.StatusCode 404;}}/// summary/// 排除 Elmah 404 寄信通知/// /summarypublic void ErrorMail_Filtering(object sender, ExceptionFilterEventArgs e){if (e.Exception is HttpException httpException (httpException.GetHttpCode() 404 || httpException.Message.StartsWith(_exceptionMsg))){e.Dismiss();}}/// summary/// 自定 Elmah 發信主旨/// /summaryprivate void ErrorMail_Mailing(object sender, Elmah.ErrorMailEventArgs e){string machineName none server;try{if (Request ! null){machineName Request.ServerVariables[HTTP_HOST];}}catch{}// 取得 Elamh ErrorMail 的主旨// $MachineName$ at $ErrorTime$ : {0}string elmahSubject e.Mail.Subject;//替換 ErrorMail 的主旨內容string emailSubject string.Format(ResearchManager.Web Error {0},elmahSubject.Replace($MachineName$, machineName));e.Mail.Subject emailSubject;}#endregion Elmah} } 运行效果运行项目http://localhost//profiler/results-index  即可看到监测结果
http://www.yutouwan.com/news/442286/

相关文章:

  • 网站设置桌面快捷方式时尚网站设计案例
  • 公司网站建设入哪科目wordpress 挂码
  • 建投能源公司简介网站seo优化网站
  • 公司网站 cmspixso在线设计平台
  • 网站建设服务费交印花税吗开发网站的语言
  • 对电子商务网站建设的理解建站平台加盟
  • 创建网站超链接成都市建设相关网站
  • 企业网站建设验收成全视频免费观看在线看第6季动漫版
  • C 做的窗体怎么变成网站2022app分类排行
  • 营销型网站制作msgg做网站如何防止被骗
  • 儿童摄影网站模板百度站长工具链接提交
  • 黄山网站设计公司浙江省住建厅证书查询
  • 网站建设主要包括哪两个方面国内做网站的公司
  • 珠海seo网站建设织梦旅游网站模板
  • 南宁做网站的有几家网站建设 运维 管理
  • 外贸社交网站排名城乡建设管理局网站
  • 上海网站建设 迈中国世界排名前300的大学
  • 网站开发去哪里找工作wap网站系统
  • 如何建设国外的网站杭州住房和城乡建设厅官网
  • 网站发展趋势毕业设计题目怎么选题
  • 做门户网站起什么域名好外贸网站和内贸
  • 莱州相亲网站自己怎么制作企业网站
  • 攸县网站建设最好的线上编程培训机构
  • 江门城乡建设局官方网站音乐网站制作教程
  • 国外公司网站设计台州做网站是什么
  • 做网上招聘哪个网站好网站推广目的
  • 台州做微网站小制作小发明视频
  • 做金融的网站画册设计是什么
  • 建设网站工作报告wordpress儿童主题
  • 网站开发和运行 法律微信网站建设费用计入什么科目