-
Notifications
You must be signed in to change notification settings - Fork 414
Configuration
When Glimpse is installed from NuGet, it is configured with settings that work for most web apps. You can easily make changes to the configuration to meet your requirements.
At its core, Glimpse is configured with a custom section called <glimpse>
in your web application's web.config
file. Installing using NuGet will automatically update web.config
to the minimal configuration.
Configuration options:
Glimpse's minimal configuration adds a custom configuration section, and registers a HTTP module and HTTP handler.
Glimpse adds a custom <section>
in the <configSections>
, named glimpse
, in the web.config
file.
<configuration>
<configSections>
<section name="glimpse" type="Glimpse.Core.Configuration.Section, Glimpse.Core" />
</configSections>
</configuration>
Glimpse adds a custom HTTP module and HTTP handler with ASP.NET.
Under <system.webServer>
, for in IIS 7 and higher:
<system.webServer>
<modules>
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode"/>
</modules>
<handlers>
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
</handlers>
</system.webServer>
Under <system.web>
, for in IIS 6 and lower:
<system.web>
<httpModules>
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet"/>
</httpModules>
<httpHandlers>
<add path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet"/>
</httpHandlers>
</system.web>
You can change Glimpse's behavior by:
- Changing which tabs are displayed.
- Enabling, disabling and customizing security policies.
- Changing the logging level.
You can disable Glimpse tabs by instructing Glimpse to ignore their types:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<tabs>
<ignoredTypes>
<add type="{Namespace.Type, AssemblyName}"/>
</ignoredTypes>
</tabs>
</glimpse>
The default Glimpse tabs are:
- Diagnostics:
- ASP.NET:
-
Configuration -
Glimpse.AspNet.Tab.Configuration
-
Environment -
Glimpse.AspNet.Tab.Environment
-
Request -
Glimpse.AspNet.Tab.Request
-
Routes -
Glimpse.AspNet.Tab.Routes
-
Server -
Glimpse.AspNet.Tab.Server
-
Session -
Glimpse.AspNet.Tab.Session
-
Configuration -
- ASP.NET MVC:
-
Execution -
Glimpse.Mvc.Tab.Execution
-
Metadata -
Glimpse.Mvc.Tab.Metadata
-
Model Binding -
Glimpse.Mvc.Tab.ModelBinding
-
Views -
Glimpse.Mvc.Tab.Views
-
Execution -
- ADO.NET:
-
SQL -
Glimpse.ADO.Tab.SQL
-
SQL -
The following markup disables several tabs:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<tabs>
<ignoredTypes>
<add type="Glimpse.AspNet.Tab.Configuration, Glimpse.AspNet"/>
<add type="Glimpse.Core.Tab.Timeline, Glimpse.Core"/>
<add type="Glimpse.Core.Tab.Trace, Glimpse.Core"/>
<add type="Glimpse.AspNet.Tab.Environment, Glimpse.AspNet"/>
<add type="Glimpse.AspNet.Tab.Request, Glimpse.AspNet"/>
</ignoredTypes>
</tabs>
</glimpse>
You can't disable the Ajax or History tabs, because they're integral to Glimpse.
Policies control what Glimpse is allowed to do to any given request. Policies can be disabled and customized to simplify some scenarios.
For example, to run Glimpse on a remote server (for example on Azure), disable the LocalPolicy
:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd" >
<runtimePolicies>
<ignoredTypes>
<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet"/>
</ignoredTypes>
</runtimePolicies>
</glimpse>
Security warning: When the markup above is used and local policy is ignored, every request can display Glimpse data. Production apps should limit who can view Glimpse data. See
Similarly, the ControlCookiePolicy
can be disabled to remove the need to turn Glimpse on and off in the browser:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<runtimePolicies>
<ignoredTypes>
<add type="Glimpse.Core.Policy.ControlCookiePolicy, Glimpse.Core"/>
</ignoredTypes>
</runtimePolicies>
</glimpse>
Glimpse will never be allowed more permissions than the defaultRuntimePolicy
allows. On
and Off
are the simplest configuration values, but there are many more options:
-
Off
: Does not allow Glimpse to perform any operations or capture any data. -
PersistResults
: Allows Glimpse to only capture request metadata. -
ModifyResponseHeaders
: Allows Glimpse to write custom headers and set cookies on HTTP responses in addition to capturing and persisting results. -
ModifyResponseBody
: Allows Glimpse to write to a HTTP response body, in addition to modifying headers and to capture and persist results. -
DisplayGlimpseClient
: Allows Glimpse to write the Glimpse JavaScript client<script>
tag to the HTTP response body, in addition to writing headers and to capture and persist results. -
On
: Allows Glimpse to run all above mentioned operations against an HTTP request/response.
In addition to the above policy configuration options, some policies allow for additional configuration:
Content Types that Glimpse will respond to can be added and removed with the <contentTypes>
whitelist element.
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<runtimePolicies>
<contentTypes>
<add contentType="application/xml"/>
<!-- <clear/> -->
</contentTypes>
</runtimePolicies>
</glimpse>
Status Codes are similar to content types in that the status codes that Glimpse will respond to can be added and removed with the <statusCodes>
whitelist element.
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<runtimePolicies>
<statusCodes>
<add statusCode="404"/>
</statusCodes>
</runtimePolicies>
</glimpse>
URIs that Glimpse will respond to can be filtered with the <uris>
blacklist element of regular expressions. This example disables Glimpse for all requests to /admin
for the configured web application.
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<runtimePolicies>
<uris>
<add regex=".*/admin.*"/>
</uris>
</runtimePolicies>
</glimpse>
If you're having problems with Glimpse, you can enable the internal Glimpse diagnostics log:
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<logging level="Trace" />
</glimpse>
The level
attribute can be set to Trace
, Debug
, Info
, Warn
, Error
or Fatal
. The default value is Off
.
The <logging>
element has an additional attribute called logLocation
which sets the location of the log file. By default, logLocation
is Glimpse.log
in your web application's root directory.