ASP.NET MVC Diagnostics Using NuGet

asp.net, asp.net mvc, nuget, code 0 comments suggest edit

Sometimes, despite your best efforts, you encounter a problem with your ASP.NET MVC application that seems impossible to figure out and makes you want to pull out your hair. Or worse, it makes you want to pull out my hair. In some of those situations, it ends up being a PEBKAC issue, but in the interest of avoiding physical harm, I try not to point that out.

pebkac-comic

Thankfully, in the interest of saving my hair, Brad Wilson (recentlyfeatured on This Developer’s Life!) wrote a simple diagnostics web page for ASP.NET MVC that you can drop into any ASP.NET MVC application. When you visit the page in your browser, it provides diagnostics information that can help discover potential problems with your ASP.NET application.

To make it as easy as possible to use it, I created a NuGet package named “MvcDiagnostics”. If you’re not familiar with NuGet, check out my announcement of NuGet as well as our Getting Started guide written by Tim Teebken.

With NuGet, you can use the Add Package Library Dialog to install MvcDiagnostics. Simply type in “MVC” in the search dialog to filter the online entries. Then locate the MvcDiagnostics entry and click “Install”.

add-package-dialog

Or you can use the Package Manager Gonsole and simply type:

install-package MvcDiagnostics

Either way, this will add the MvcDiagnostics.aspx page to the root of your web application.

mvcdiagnostics-viewinbrowser

You can then visit the page with your browser to get diagnostics information.

mvc-diagnostics

With NuGet, it’s much easier to make use of this diagnostics page. Hopefully you’ll rarely need to use it, but it’s nice to know it’s there. Let us know if you have ways to improve the diagnostics page.

Found a typo or error? Suggest an edit! If accepted, your contribution is listed automatically here.

Comments

avatar

13 responses

  1. Avatar for Brad Wilson
    Brad Wilson December 5th, 2010

    In fairness, MvcDiagnostics was the brain-child of the brilliant but blogless Levi Broderick. I just got to document its existence. :)

  2. Avatar for Richard McCutchen
    Richard McCutchen December 5th, 2010

    Phil,
    Maybe you can help me out here, when I tried install-package MvcDiagnostics in the NuGet console I got the following error:
    Install-Package : [A]NuGet.Manifest cannot be cast to [B]NuGet.Manifest. Type A originates from 'NuGet.Core, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' in the context '
    Default' at location 'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\NuGet.Core\v4.0_1.0.0.0__31bf3856ad364e35\NuGet.Core.dll'. Type B originates from 'NuGet.Core, Version=1.0.0.0, Culture=neutral
    , PublicKeyToken=31bf3856ad364e35' in the context 'LoadFrom' at location 'C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\Extensions\Outercurve Foundation\NuGet Tools\0.2\NuGet.Core.
    dll'.
    At line:1 char:16
    + install-package <<<< MvcDiagnostics
    + CategoryInfo : NotSpecified: (:) [Install-Package], InvalidCastException
    + FullyQualifiedErrorId : NuGet.VisualStudio.Cmdlets.InstallPackageCmdlet
    Have any idea what's causing this and how I can resolve it? Thanks ;)

  3. Avatar for BlueCoder
    BlueCoder December 5th, 2010

    Just install it and run it. I enjoy working with NuGet I feel more professional !

  4. Avatar for Sergio Tapia
    Sergio Tapia December 5th, 2010

    This seems very useful. I'm going to try it out, thanks for sharing!

  5. Avatar for Pierrick
    Pierrick December 5th, 2010

    Nice work! Would be nice to see a razor version too :) I guess it's not too hard to convert it!

  6. Avatar for Imran
    Imran December 5th, 2010

    I was aware about that diagnostic page with the help of awesome Levi Broderick.

  7. Avatar for Ray
    Ray December 5th, 2010

    I tried install-package mvcdiagnostics, but the .aspx page was never added. Any ideas?

  8. Avatar for Paul
    Paul December 5th, 2010

    I am not seeing the MvcDiagnostics as an available package? On a side note, if you have not seen this (http://www.thewebsiteisdown.com/) watch video one. Best example of PEBKAC

  9. Avatar for haacked
    haacked December 6th, 2010

    @Ray try it again? It worked for me.
    @Paul try it again? I see it there.

  10. Avatar for Jason
    Jason December 21st, 2010

    It's dead, Jim.
    haacked.com/...

  11. Avatar for Vishal Patwardhan
    Vishal Patwardhan February 13th, 2011

    Hi, i am using the follow routing in my asp.net mvc2
    routes.MapRoute("Default", "{controller}/{action}/{id}", new {controller="Home",action="Index",id=UrlParameter.Optional});
    still this is showing me directory listing but whenever i type the hardcoded url say : localhost:xxxx/Default this is showing the appropriate page. what should i Do?

  12. Avatar for Nay
    Nay December 11th, 2011

    So this is the error I got:
    An ASP.NET MVC assembly has not been loaded into this application.
    Any ideas on where to go from here to get it fixed?
    Thanks

  13. Avatar for haacked
    haacked December 11th, 2011

    @Nay, that looks like you don't have ASP.NET MVC assemblies deployed to your server. Have you heard this? haacked.com/.../bin-deploying-asp-net-mvc-3.aspx