In my previous post (not so long ago). I talked about the Actionlink and it not being very refactor friendly because of all the magic strings in it.

But there was a strongly typed version out there somewhere that didn’t work all the time but I couldn’t find it at that time.

Well it is hiding here and you can dowload it by clicking on the ASP.NET MVC v1.0 Futures link.

This is a dll so store it somewhere in your project and then reference itfrom your project. The dll and the namespace cary the name Microsoft.Web.Mvc unlike the real Mvc which resides in System.Web.Mvc.

Now how do we get our strongly typed Actionlink to work. Simple.

First we make sure our method doesn’t have the ActionName attribute on it.

public ActionResult Person()
        {
            var person = personRepository.FindPerson(1);
            return View("Person",person);
        }```
And then in our Site.Master page we add this somewhere near the top.

```asp
<%@ Import Namespace="Microsoft.Web.Mvc"%>

And now both these links produce the same result.

asp <li><%= Html.ActionLink("Person", "Person", "Person")%></li> <li><%= Html.ActionLink<PersonController>(e => e.Person(),"Person")%></li> Now if I refactor the Method name Person to PersonPage for instance.

csharp public ActionResult PersonPage() { var person = personRepository.FindPerson(1); return View("Person",person); } it will also rename the function for me or give a compile error which we prefer over a runtime error.

asp <li><%= Html.ActionLink("Person", "Person", "Person")%></li> <li><%= Html.ActionLink<PersonController>(e => e.PersonPage(),"Person")%></li> So now the first line doesn’t work but the second still does without much effort.