MvcMiniProfiler 分析 Web 应用程序和较低层
我已在 ASP.NET MVC 应用程序中设置并运行 MiniProfiler。我的控制器通过 WCF 调用 BLL,而 BLL 又与数据库通信。我希望看到 WCF 服务的分析以及我从 Web 应用程序看到的现有分析。是否是在所有服务调用中将 MiniProfiler 作为参数的情况?
I have MiniProfiler set up and working in my ASP.NET MVC app. My controllers make calls via WCF to a BLL which in turn talks to the database. I would like to see profiling from the WCF service alongside the existing profiling I see from the web app. Is it a case of making MiniProfiler a parameter in all service calls?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在最近发布的 MvcMiniProfiler 中,他们添加了 WCF 支持(版本 1.8 或更高版本)。这是完成此工作的 3 个步骤过程:
添加引用
首先通过 nuget 在 UI 层和 WCF 层中添加对 MvcMiniprofiler 和 MvcMiniProfiler.WCF 的引用(或下载源代码并编译您自己的源代码)。
设置 WCF 主机
其次,在服务主机的 web.config 中,您必须将微型分析器添加为端点行为。所有配置部分都属于“configuration/system.serviceModel”。
然后添加行为扩展(请注意,版本号需要与您的 MvcMiniProfiler.WCF 版本相匹配):
然后设置端点以使用您设置的探查器行为:
取决于您的设置,但我必须再添加一项 web.config 设置为所有请求运行所有托管模块。此配置位于根“配置”部分:
设置 WCF 客户端
最后,通过执行与上面相同的操作来设置 WCF 客户端以“打开”mvc 探查器。
添加扩展:
添加行为:
设置端点以使用该行为:
您就完成了!
旁注:
MvcMiniProfiler 实际上如何在 WCF 上工作?
基本上,客户端行为会设置一个 SOAP 标头,告诉 wcf 主机打开探查器。它传递由 WCF 主机端的端点行为读取的标头。然后它会在主机中打开分析器。最后,当 WCF 主机回复客户端时,它将所有探查器优点填充到 SOAP 响应标头中,该标头又由 WCF 客户端读取。相当巧妙。
In a recent release of the MvcMiniProfiler they added WCF support (version 1.8 or greater). This is a 3 step process to get this working:
Add References
First add references to the MvcMiniprofiler and MvcMiniProfiler.WCF in your UI layer and WCF layer via nuget (or download the source and compile your own).
Setup WCF Host
Second, within the web.config of the service host you have to add the miniprofiler as an endpoint behavior. All of the config sections belong in "configuration/system.serviceModel".
Then add the behavior extension (Note the version number needs to match your version of the MvcMiniProfiler.WCF):
Then setup the endpoints to use the profiler behavior you setup:
Depends on your setup but I had to add one more web.config setting to run all managed modules for all requests. This config is in the root "configuration" section:
Setup WCF Client
Last, setup the wcf client to "turn on" the mvc profiler by doing much the same above.
Add the extension:
Add a behavior:
Setup the endpoints to use that behavior:
And you're done!
Side Note:
How does the MvcMiniProfiler actually work over WCF?
Basically the client behavior sets up a SOAP header that tells the wcf host to turn on the profiler. It passes that header along which is read by the endpoint behavior on the WCF host side. It then turns the profiler on in the host. Lastly when the WCF host is replying back to the client it stuffs all the profiler goodness into the SOAP response header which is in turn read by the WCF client. Pretty ingenious.
这是一种方法,但为了获取对库的引用,您必须在 MvcMiniProfiler 的较低层中添加引用。
在这种完全相同的情况下,我所做的是利用 MiniProfiler 作为单例提供的全局访问点。因此,我只是在较低层中添加了引用(删除了与 MVC 相关的内容,例如视图),并且只使用了 MiniProfiler.Current,就好像我在上层一样。
它就像一个魅力。 :)
That's one method, but in order to get the reference to the libraries you would have to add references in the lower layers for MvcMiniProfiler anyway.
What I did in this very same situation is to take advantage of the global access point that MiniProfiler provides as a singleton. So, I just added the reference in the lower levels (deleted the stuff relative to MVC, such as the views) and just used MiniProfiler.Current as if I were on the upper layers.
It works like a charm. :)