An even better way to run T4MVC: a VS AddIn

Last week, I blogged about a nice way of auto-running T4MVC by using the Macro IDE to write an OnBuildBegin event handler.  This was a big improvement over the hacky ‘AlwaysKeepTemplateDirty’ flag that we’ve been using since T4MVC’s early days. Since then, Wayne Brantley has taken this idea to the next level by turning it…

8

A better way to auto-run T4MVC when you build

Update: also see the newer post on this topic   T4MVC has always struggled with finding the right way of running automatically when you build.  Being a T4 template in your project, by default it just runs when you save it.  This is not great, because you really want it to rerun whenever you make…

16

T4MVC 2.6.13: now officially in MvcContrib, with a few new features

To get the latest build of T4MVC: Go to MvcContrib T4MVC page on CodePlex   A few weeks back, we announced (mostly on Twitter) that T4MVC was moving into the MvcContrib Codeplex project.  I didn’t say much about it at the time because there wasn’t a whole lot to say yet, in the sense that…

1

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

Use C# 4.0 dynamic to drastically simplify your private reflection code

Update 8/10/2011: this project now has a home at https://github.com/davidebbo/ReflectionMagic. Also, it is installable via nuget. It’s named ‘ReflectionMagic’.   Private reflection allows you to access private and internal members in other assemblies.  Generally, it’s considered to be a bad thing to do, as it ties you to undocumented implementation details which can later break you. …

15

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

T4MVC 2.6.10: fluent route value API, shorter way to refer to action, and more

To get the latest build of T4MVC: Go to T4MVC page on CodePlex I just posted build 2.6.10.  There were also a few builds in between since I last blogged about 2.6, so this post describes some of those changes (full history here). Fluent route value API As you probably know, T4MVC uses a pattern…

7

Passing anonymous objects to MVC views and accessing them using dynamic

Note (12/22/2011): now that MVC 3 has direct support for dynamic, the technique below is no longer necessary. This post is in fact what led to integrating the feature into MVC! First, I’ll start with a little disclaimer: this post is not about whether using dynamic is better/worse than static typing.  Instead, it’s about making…

26

T4MVC 2.6: MVC 2 Areas support

To get the latest build of T4MVC: Go to T4MVC page on CodePlex One of MVC 2’s major new features is the support for breaking up a large application into “Areas”. This works by following a structure that looks like: Root folder Models Views Controllers Areas NerdDinner Models Views Controllers Blog Models Views Controllers So…

14

T4MVC now has a real home and a dedicated forum!

Up until now, most things related to T4MVC were happening through my various blog posts about it.  And while that was sort of working ok for a while, it was also less than ideal for a couple reasons. First, there was no single place to go to in order to get information about it.  You’d…

5