Debugging ASP.NET generated code

Update 2/4/2010: changed Technique #2 to use Debugger.Break()   This post applies to any ASP.NET app that uses .aspx files, whether WebForms or MVC. When you write an aspx/ascx/master file (I’ll just say aspx for here on, but it applies to all), it gets compiled dynamically by the ASP.NET runtime.  Note that this is true…

12

Take your MVC User Controls to the next level

Note: this is based on ASP.NET MVC 2 RC, and will not work on earlier builds.   The quick pitch: make your User Controls as cool as built-in render helpers! The goal of this post is to show you how to change the way MVC user controls are called from something like this: <%= Html.Partial("~/Views/Shared/gravatar.ascx",…

31

CodeDom vs T4: two approaches to Code Generation

There are many scenarios where the need to generate source code arises.  The MVC helpers I introduced in my last post is one such example.  Note that I am focusing on generating source code here, and not on scenarios where you may want to generate IL directly (which certainly do exist as well, but it’s…

16

A BuildProvider to simplify your ASP.NET MVC Action Links

Update: Please see this newer post for the latest and greatest MVC T4 template   One downside of using Html.ActionLink in your views is that it is late bound.  e.g. say you write something like this: <%= Html.ActionLink("Home", "Index", "Home")%> The second parameter is the Action name, and the third is the Controller name.  Note…

29