Patrice Calve

Life's short, have fun
posts - 51, comments - 49, trackbacks - 31

My Links

News

Archives

Post Categories

Image Galleries

Thursday, October 30, 2008

ASP.Net MVC Beta - ActionLink isn't generic anymore

Hi,

I just "migrated" from ASP.Net MVC Preview 5 to ASP.Net MVC Beta.  I uninstalled Preview 5 and installed the Beta.  I already had checked out previous previews but spent the most time with Preview 5, and didn't want to upgrade my "Preview-5-version-of-my-test-website" just in case there were deprecated or new features, specially in the "New ASP.Net MVC Application" template.  Gutt feeling.  So I created a new Project.

In Preview 5 release, the Html.ActionLink accepted a generic parameter list, with lambda expression, allowing to strongly-type the controller and it's method, including its parameters.  I really like this right now (my bubble may blow one day).

The syntax would look like this:

 <%= Html.ActionLink<CalveNet.Controllers.PatwareController>(c => c.Index(), "Here")%>

After creating my project, I copied a few files over (aspx pages, controllers, etc.).  But Visual Studio complained that the

"The non-generic method 'System.Web.Mvc.Html.LinkExtensions.ActionLink(System.Web.Mvc.HtmlHelper, string, string)' cannot be used with type arguments"

I found out that this generic/lambda version of the parameter is from a separate dll, called "ASP.NET MVC Beta Futures". 

To make it work, unzip the file, include the "Microsoft.Web.Mvc.dll" to your references, and don't forget to include the namespace in your web.config, under the path:

/configuration/system.web/pages/namespaces

add the following: <add namespace="Microsoft.Web.Mvc"/>

Pat

posted @ Thursday, October 30, 2008 8:09 PM | Feedback (10) |

Powered by: