[Go] Use Glimpse to monitor ASP. NET MVC website

Source: Internet
Author: User

Using Miniprofiler to debug ASP. NET MVC Web site performance, Miniprofiler can handle the event of each processing time on the back end of the website very well, but Miniprofiler is unable to do remote monitoring of the action, The Miniprofiler is only capable of monitoring local-side actions, so miniprofier is more suitable for use during development.

When developing ASP. NET Webfrom, if you want to track the performance and performance of each page, you can actually use the "Trace" function, so that you can display the full details of the page execution at the bottom of each page, including the Http Request from the front-end, all Session, cookies, etc., for the development period, this information can help us in the wrong time to grasp the exact information, however, after the system on-line, Trace function is bound to close, and alone by ELMAH record error message is not fully mastered, Because sometimes doing normal does not mean that the function is normal, such as slow running time, path error, etc.

The next step is to introduce "Glimpse", in addition to the function with Trace, can also be combined with the login authentication of Forms authentication, let us after the system on-line, the same can be real-time for developers to track the page execution of information.

Glimpse is a model. NET performance testing tools, support for ASP., ASP, EF, etc., the advantage is that there is no need to modify the original project any code, and can output the execution of the code execution time, the installation is very simple, through NuGet directly installed.

Glimpse

http://getglimpse.com/

Http://nuget.org/List/Packages/Glimpse

What is Glimpse At it core Glimpse allows you-to-debug your Web site or Web service right in the browser. Glimpse allows "Glimpse" into what's going on your Web server. In and words what Firebug are to debugging your client side code, Glimpse are to debugging your server within the client.
fundamentally Glimpse is made up of 3 different parts, all of which was extensible and customizable for any platform:< /c0>
    • Glimpse Server Modules –code on the Web server so collects meta data and sends it to the client.
    • Glimpse Protocol –a specification of that meta data.
    • Glimpse Client Side Viewer –code on the Web page or in the browser that takes the meta data from the server and Displays it to the user.

Note on the official website, currently Glimpse supports ASP. NET WebForm with ASP.

Glimpse has the appearance of Firefox-like Firebug, can be executed at any time after the function of the expansion or closing, but Glimpse is not any browser plug-in, Glimpse is a dependency on the creation of JQuery plugin, so your site must be introduced to use JQuery, while the browser is not limited, according to the information displayed on the official website, Glimpse can support a variety of browsers: Chrome, Firefox 4 and IE9.

Use NuGet installation Glimpse

The Glimpse package above NuGet currently only supports ASP. NET MVC3

After the installation is complete, Glimpse for ASP. NET Beta () is installed, and a new folder "App_readme" is created in the scenario after installation, with two Readme files in it, "glimpse.readme.txt "In the contents of the file, instructions on how to modify the Web. config and feature description

through NugGet installation Glimpse , in Web. config What did you add ?

Basically the installation is ready to use, but before using it, take a look at what the Web. config has, and add the "glimpse" setting in the first configsections

Then there was an increase in httpmodules and httphandlers in System.Web, and in modules and handlers in system.webserver.

And in the last side of Web. config there is a glimpse section, in this section, you can change the settings for different situations, the default setting is Enabled= "true", the default is to glimpse function to open

In Glimpse.readme.txt, there is a description of how the section of Glimpse is set:

The following configuration values is allowed for Glimpse in your web. config:<Glimpseenabled= "true"requestlimit= "5"loggingenabled= "false"ipforwardingenabled= "false"cacheenabled= "true">     <!--set enabled to False to completely turn off Glimpse.         REQUESTLIMIT Specifies the max number of requests Glimpse would save. EnableLogging (False by default) if you experience problems with Glimpse ipforwardingenabled (false by default) WI ll force Glimpse to validate IP addresses based on the value in the Http_x_forwarded_for header.        Useful if your server is behind a proxy or load balancer. Cacheenabled (True by default) Glimpse would tell browsers to the cache static files by default -    <ipaddresses> <!--List of IP addresses allowed to get Glimpse data. Optional. LocalHost (IPv4 & IPv6) by default -        <AddAddress= "127.0.0.1" />        <AddAddress= ":: 1" />    </ipaddresses>    <ContentTypes><!--List of content types Glimpse would provide data for. Optional text/html and Application/json by default -        <AddContentType= "text/html"/>    </ContentTypes>    <pluginblacklist><!--List of plugins for Glimpse to ignore. Optional. By default all plugins would load -        <Addplugin= "Glimpse.Core.Plugin.Request"/>        <Addplugin= "Glimpse.Core.Plugin.MetaData"/>    </pluginblacklist>    <Environments><!--List of environments your application runs in. Used for the new environment Switcher feature. Optional. By default environment information'll no be shown -        <Addname= "Dev"Authority= "localhost:33333" />        <Addname= "Prod"Authority= "Getglimpse.com" />    </Environments>    <urlblacklist><!--Glimpse would ignore all requests made to the URI ' s that match any regular expression in the this list. Optional. By default all URI ' s would be considered for Glimpse inspection.  -        <AddURL= "{regex}"/>        <AddURL= "{regex}"/>    </urlblacklist></Glimpse>

To turn on the use of Glimpse is quite simple, just enter "http // your website URL /glimpse.axd" On it, you will go to the following page

Then go back to the Site page, you can see the bottom right corner of the page appears an icon, directly click on the icon

There will be more commonly used Ajax, Config, enviroment, execution, Request, Server, Trace, views.

The problem with ELMAH is the same, that is, pre-installed, can be anonymous browsing, for the security of the site is a considerable threat, especially the Glimpse config, will be all the information of Web. config is fully present, so this article will explain how to make Glimpse can only be used after logging in.

Change Web. config of the Glimpse Configuration

In the Readme.txt provided by Glimpse, there is already a description of how to modify, so that enable Glimpse must be logged in before you can,

1 <Glimpseenabled= "true"loggingenabled= "true" />2 3 can be added loggingenabled= "true", but this is not enough, it must be further to prevent anonymous users to enter directly, so modify the following:4 5 <Glimpseenabled= "true"loggingenabled= "true" />6 7 < LocationPath= "Glimpse.axd">8 9 <system.web>Ten  One <Authorization> A  - <DenyUsers="*" /> -  the </Authorization> -  - </system.web> -  + </ Location>

If you want further protection, you can specify which users will be able to use or restrict which role permissions are available to users, so my changes are as follows:

1 <Glimpseenabled= "true"loggingenabled= "true" />2 3 < LocationPath= "Glimpse.axd">4 5 <system.web>6 7 <Authorization>8 9 < AllowRoles= "Admin"/>Ten  One <DenyUsers="*" /> A  - </Authorization> -  the </system.web> -  - </ Location>

This prevents anonymous users from using the Glimpse feature, and only uses users with admin role privileges to be able to use it, and the user who is not the admin role will be directed back to the page when they enter "http://your URL/glimpse.axd". For detailed Glimpse section setting, I suggest to read the official website's instructions:

Glimpse Document Configuration
Http://getglimpse.com/Help/Configuration

Also note that if you only want to enable glimpse in the development environment, and in the formal environment do not want to enable glimpse, do not need to go online before the glimpse to remove, just to change the Glimpse section settings can be,< Glimpse enabled= "false" loggingenabled= "true"/> Change the original enabled= "true" to Enabled= "false".

In fact glimpse can combine ELMAH, let ELMAH recorded error message in glimpse, after the system login authentication, as long as enable glimpse can go to see ELMAH record data, no need to enter ELMAH,

Next, we'll show you how to install Elmah plugin for Glimpse and some of the modification settings through NuGet.

Please remember that your site must show that you have installed ELMAH and Glimpse,nuget search Glimpse to find "elmah plugin for glimpse"

After the installation is complete, you can see the "elmah" tab in the Glimpse function window after you open glimpse on your website.

RELATED links:

Http://www.hanselman.com/blog/NuGetPackageOfTheWeek5DebuggingASPNETMVCApplicationsWithGlimpse.aspx

Http://stackoverflow.com/questions/5746444/should-i-deploy-glimpse-to-the-production-site

Debugging an ASP. NET MVC application using Glimpse

Elmah for glimpse–best of Both Worlds

Using Glimpse with ASP.

[Go] Use Glimpse to monitor ASP. NET MVC website

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.