Raj Aththanayake's Blog Raj Aththanayake's Blog | April 2011

Glimpse

26. April 2011

Few years back, Phil Haack introduced a Routing Debugger. You might have also seen this nice Mvc Route Debugger Visualizer.

What I’m about to show you is a really cool tool, which allows you to debug ASP.NET MVC applications. It is called Glimpse. Glimpse includes not only route debugging support but also many other features. As you know Firebug is a debugging tool for client, and Glimpse does it for the server. Glimpse only works with the version MVC3. It can support MVC2, however you need to have MVC3 installed. It should support ASP.NET Web Forms as well but the current release (beta version) has dependencies to MVC.  I haven’t tried the Glimpse Web Forms debugging yet, but it is supported.

NuGet:

 

PM> Install-Package Glimpse

You can configure Glimpse by navigating to

http://localhost:<port#>/Glimpse/config

Below is how you see Glimpse while debugging information.

You can debug : Application settings, routes, session variables, trace data.

If it is an Ajax request, then the server embeds the JSON in the content of the page. And many more...

You can see a nice video and more information here.

So if you haven’t started using this, I suggest you download it, as it will definitely assist your development work!

 

ASP.NET / ASP.NET MVC

Getting Started with T4MVC

24. April 2011

This post is about T4MVC and how you would use it within your MVC application. T4MVC is a great way to generate strongly typed helpers so you can eliminate the use of literal strings when referring to Actions, Controller, and Views within your MVC application.

How to install T4MVC?

You have 2 options.

a.    Download from MvcContrib CodePlex project. http://mvccontrib.codeplex.com/releases/view/41582

 

b.    Use NuGet

http://nuget.codeplex.com/wikipage?title=Getting%20Started

 

NuGet Approach      

Open VS2010. Tools,  Library Package Manager, and Package Manager Console. Execute the following command.

PM> install-package T4MVC

This should install 2 files under your app’s root folder.

T4MVC.tt and T4MVC.tt.settings.t4 - These files contain necessary entries which allow you to use T4 strongly typed helpers.

 

Once you install T4MVC, you might also notice couple errors appeared in the Error List window. (Please see below)  

 

As you see, there are no auto generated files being added to the solution yet. You would continue to get these errors if you decided to build the solution.

To remove these errors, you need to run Custom Tool on the T4MVC.tt file. (Right click on the file and select “Run Custom Tool”).Now you should be able to see additional auto generated files added to the solution.

 

T4MVC in Action

Below are few examples of the usage of T4MVC.

 

 

As you see T4MVC generates the strings accordingly.

Where to find more information?

T4MVC templates are part of MVCContrib project and developed by David Ebbo. If you would like to know more information please visit the link below.

http://mvccontrib.codeplex.com/wikipage?title=T4MVC_doc&referringTitle=T4MVC 

 

ASP.NET / ASP.NET MVC