I want to add glimpse diagnostic tool to my mvc4 hot-towel project.
I am following instruction http://nuget.org/packages/Glimpse.Mvc4/ and installing mvc4 nuget package of glimpse in my project.
It is getting installed properly and getting dependency and updating web.config as shown below.
<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>
and
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
<add name="Glimpse" path="glimpse.axd" verb="GET" type="Glimpse.AspNet.HttpHandler, Glimpse.AspNet" preCondition="integratedMode" />
</handlers>
<validation validateIntegratedModeConfiguration="false" />
<modules>
<add name="Glimpse" type="Glimpse.AspNet.HttpModule, Glimpse.AspNet" preCondition="integratedMode" />
</modules>
and
<glimpse defaultRuntimePolicy="On" endpointBaseUri="~/Glimpse.axd">
<!-- If you are having issues with Glimpse, please include this. It will help us figure out whats going on.
<logging level="Trace" />-->
<!-- Want to use Glimpse on a remote server? Ignore the LocalPolicy by removing this comment.
<runtimePolicies>
<ignoredTypes>
<add type="Glimpse.AspNet.Policy.LocalPolicy, Glimpse.AspNet"/>
</ignoredTypes>
</runtimePolicies>-->
However, when i run project and type url such as http://mylocalurl.com/glimpse.axd . It is not finding axd file so i am unable to enable glimpse.
P.S. I have defined custom route for loading Index page for hot-towel template.
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Load", action = "Index", id = UrlParameter.Optional }
);
}
The reason Glimpse.axd cannot be found is due to the order in which the routes are being configured.
If you install the RouteDebugger NuGet package you'll see that there is another route handling the Glimpse.axd request, namely a route installed by the Hot Towel template, which can be found inside the App_Start
folder in the class HotTowelRouteConfig
using System.Web.Mvc;
[assembly: WebActivator.PreApplicationStartMethod(
typeof(throwaway.App_Start.HotTowelRouteConfig), "RegisterHotTowelPreStart", Order = 2)]
namespace throwaway.App_Start {
///<summary>
/// Inserts the HotTowel SPA sample view controller to the front of all MVC routes
/// so that the HotTowel SPA sample becomes the default page.
///</summary>
///<remarks>
/// This class is discovered and run during startup
/// http://blogs.msdn.com/b/davidebb/archive/2010/10/11/light-up-your-nupacks-with-startup-code-and-webactivator.aspx
///</remarks>
public static class HotTowelRouteConfig {
public static void RegisterHotTowelPreStart() {
// Preempt standard default MVC page routing to go to HotTowel Sample
System.Web.Routing.RouteTable.Routes.MapRoute(
name: "HotTowelMvc",
url: "{controller}/{action}/{id}",
defaults: new
{
controller = "HotTowel",
action = "Index",
id = UrlParameter.Optional
}
);
}
}
}
And since this route will be added before the execution of the RouteConfig.RegisterRoutes
(due to the use of WebActivator
), it will handle the request for Glimpse.axd, because that route has default values for every route parameter and therefore will match the Glimpse.axd request.
You can solve this by removing the HotTowelRouteConfig
but then you'll have to go the example url explicitly http://mylocalurl.com/HotTowel/Index
, or you remove the WebActivator
part from the HotTowelRouteConfig
[assembly: WebActivator.PreApplicationStartMethod(
typeof(throwaway.App_Start.HotTowelRouteConfig), "RegisterHotTowelPreStart", Order = 2)]
and register the route explicitly in the RouteConfig.RegisterRoutes
by calling HotTowelRouteConfig.RegisterHotTowelPreStart()
after the call to routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
that way you'll still have the example by default and Glimpse.axd will be handled as expected.
Either way, both options involve removing or changing files managed by the HotTowel NuGet package, so maybe the example should be put into its own NuGet package (you don't want to bring the example into production for instance)