Use Glimpse to monitor ASP. net mvc websites

Source: Internet
Author: User
Tags website performance

Use MiniProfiler to debug ASP. net mvc website performance. MiniProfiler can handle events at each processing time on the back end of the website. However, MiniProfiler cannot be used for remote monitoring. MiniProfiler can only monitor local operations, therefore, MiniProfier is suitable for use during development.

In the development of ASP. NET WebFrom, if you want to track the execution status and performance of each page, you can actually use the "Trace" function, in this way, the complete details of page execution can be displayed at the bottom of each page, including the Http Request sent by the front-end, all sessions, and cookies. During the development period, this information can help us grasp the exact information when debugging. However, after the system is launched, the Trace function is bound to be disabled, and the error message recorded by ELMAH cannot be fully grasped, sometimes normal execution does not indicate that the function is normal, for example, the running time is too slow or the path is incorrect,

Next, we will introduce "Glimpse". In addition to the Trace function, we can also combine Forms Authentication login Authentication, so that after the system goes online, similarly, developers can track page execution information in real time.

Glimpse is. the performance testing tool under. NET supports asp.net, asp.net mvc, EF, and so on. The advantage is that it does not need to modify any code of the original project and can output the execution time of each stage of code execution, the installation method is very simple. You can directly install it through nuget.

Glimpse

Http://getglimpse.com/

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

What is Glimpse

At its core Glimpse allows you to debug your web site or web service right in the browser. glimpse allows you to "Glimpse" into what's going on in your web server. in other words what Firebug is to debugging your client side code, Glimpse is to debugging your server within the client.
Fundamentally Glimpse is made up of 3 different parts, all of which are extensible and customizable for any platform:

  • Glimpse Server Modules-Code on the web server that 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.

On the official website, Glimpse currently supports ASP. NET WebForm and ASP. net mvc.

Glimpse has a Firebug similar to Firefox. It can be expanded or received at any time after the function is executed. However, Glimpse is not a plug-in of any browser, and Glimpse is a plug-in built on jQuery, therefore, jQuery must be introduced to your website, but the browser is not limited. Based on the information displayed on the official website, Glimpse supports multiple browsers: Chrome 12, Firefox 4 and IE9.

UseNuGetInstallGlimpse

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

After the installation is complete, Glimpse for ASP. NET Beta () will also be installed. After the installation is complete, a new folder "App_Readme" will be created in the solution, which contains two Readme files,"Glimpse.readme.txt"File content has a detailed description, describes how to modify Web. Config and function Introduction

PassNugGetInstallGlimpse, InWeb. ConfigWhat is added

Basically, you can use it after the installation is complete, but before using it, let's take a look at what is added to Web. Config and add the "glimpse" setting in configSections at the beginning.

Then, both httpModules and httpHandlers of system. web are added, and modules and handlers of system. webServer are also added.

In the Web. there is a glimpse section at the end of Config. In this Section, you can change the settings for different situations. The default setting is enabled = "true ", glimpse is enabled by default.

In glimpse.readme.txt, we will explain how to set the Section of glimpse:

The following configuration values are allowed for Glimpse in your web.config:<glimpse enabled="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 will save.         enableLogging (false by default) if you experience problems with Glimpse         ipForwardingEnabled (false by default) will 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 will tell browsers to cache static files by default    -->    <ipAddresses> <!-- List of IP addresses allowed to get Glimpse data. Optional. localhost (IPv4 & IPv6) by default -->        <add address="127.0.0.1" />        <add address="::1" />    </ipAddresses>    <contentTypes><!-- List of content types Glimpse will provide data for. Optional  text/html and application/json by default -->        <add contentType="text/html"/>    </contentTypes>    <pluginBlacklist><!-- List of plugins for Glimpse to ignore. Optional. By default all plugins will load -->        <add plugin="Glimpse.Core.Plugin.Request"/>        <add plugin="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 will no be shown -->        <add name="Dev" authority="localhost:33333" />        <add name="Prod" authority="getglimpse.com" />    </environments>    <urlBlacklist><!-- Glimpse will ignore all requests made to URI's that match any regular expression in this list. Optional. By default all URI's will be considered for Glimpse inspection. -->        <add url="{regex}"/>        <add url="{regex}"/>    </urlBlacklist></glimpse>

To enable Glimpse, you only need to enter 「Http ://Your website URL/Glimpse. axdYou can access the following page.

Go back to the website page and you will see an icon in the lower right corner of the page. Click the icon directly.

Among them, Ajax, Config, Enviroment, Execution, Request, Server, Trace, and Views are commonly used.

The problem with ELMAH is the same, that is, after the preset installation, it can be browsed anonymously, which is a great threat to website security, especially the Glimpse Config, the Web. all the information of Config is completely displayed, so this article describes how to enable Glimpse to be used after login.

ChangeWeb. ConfigOfGlimpseConfiguration

In readme.txt of the glimpse的, we have explained how to modify it. To enable Glimpse, you must log on to it,

<Glimpse enabled = "true" loggingEnabled = "true"/>

You can add loggingEnabled = "true", but this is not enough. You must further prevent anonymous users from accessing the service directly. Therefore, the modification is as follows:

<Glimpse enabled = "true" loggingEnabled = "true"/>

<Location path = "Glimpse. axd">

<System. web>

<Authorization>

<Deny users = "*"/>

</Authorization>

</System. web>

</Location>

If further protection is required, you can specify which users can use or which roles and permissions can be used by users. Therefore, my modifications are as follows:

<Glimpse enabled = "true" loggingEnabled = "true"/>

<Location path = "Glimpse. axd">

<System. web>

<Authorization>

<Allow roles = "Admin"/>

<Deny users = "*"/>

</Authorization>

</System. web>

</Location>

In this way, anonymous users are prevented from using the Glimpse function, and only users with the Admin role permission are allowed to use it. users who are not Admin roles enter "http: // your url/Glimpse. axd will be directly directed back to the home page. For details about how to set the Glimpse Section, I suggest you read the instructions on the official website:

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

In addition, if you only want to enable glimpse in the development environment and do not want to enable glimpse in the formal environment, you do not need to remove glimpse before going online, you only need to change the setting of the glimpse Section. <glimpse enabled = "false" loggingEnabled = "true"/> change the original enabled = "true" to enabled = "false.

In fact, glimpse can combine ELMAH to display the error messages recorded by ELMAH in glimpse. After the system logon authentication, you only need to enable glimpse to view the record data of ELMAH, you no longer need to enter ELMAH,

Next we will introduce how to install it through NuGetElmah plugin for GlimpseAnd some modification settings.

Remember that your website must have ELMAH and Glimpse installed. Search for Glimpse in NuGet to find "Elmah plugin for Glimpse 」

After the installation is complete, enable glimpse on your website and you will be able to see the "Elmah" tab in the glimpse function window.

 

Related links:

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

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

Use Glimpse to debug ASP. net mvc applications

Elmah for Glimpse-Best of Both Worlds

Related Article

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.