Geeks With Blogs
Patrice Calve Life's short, have fun

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 on Thursday, October 30, 2008 8:09 PM | Back to top


Comments on this post: ASP.Net MVC Beta - ActionLink isn't generic anymore

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
Thanks very much for this post Pat.

I just did some frantic googling when all my strongly typed links and forms broke!

Thanks again.
Left by Jason Summers on Nov 09, 2008 2:47 PM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
Thank you.
Left by Charles on Nov 11, 2008 9:01 AM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
Thank you!
Left by Gab on Nov 11, 2008 11:30 AM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
Thanks--this post saved me too!
Left by m on Dec 18, 2008 9:52 AM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
Thanks post saved me as well , it seems kind of obvious after reading this , i think they should have included a note in the release docs or some kind of reference to the download.
Left by Jameel on Dec 29, 2008 12:22 AM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
Add another MVC.NU-B saved to your credit. Thanks much!
Left by James Fleming on Jan 01, 2009 11:03 PM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
Hi Guys

I've downloaded ASP.NET MVC Beta Futures and add Microsoft.Web.Mvc.dll into the reference (I am testing the MvcContrib.Samples.HTMLHelper).

Add the <add namespace="Microsoft.Web.Mvc"/> into /configuration/system.web/pages/namespaces web.config.

When I ran it, I got the same error though:

Compiler Error Message: CS0411: The type arguments for method 'Microsoft.Web.Mvc.LinkExtensions.ActionLink<TController>(System.Web.Mvc.HtmlHelper, System.Linq.Expressions.Expression<System.Action<TController>>, string)' cannot be inferred from the usage. Try specifying the type arguments explicitly.

Any ideas?
Left by dewacorp.alliances on Jan 03, 2009 4:20 PM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
Continuing as per above:

The error was on line 6:

The source error:

Line 4: <p>The UI Helpers sample application currently has three helpers:</p>
Line 5: <ul>
Line 6: <li><%= Html.ActionLink("Form Helper", "FormHelper") %></li>
Line 7: <li><%= Html.ActionLink("Validation Helper", "ValidationHelper") %></li>
Line 8: <li><%= Html.ActionLink("Grid", "Grid") %></li>
Left by dewacorp.alliances on Jan 03, 2009 4:22 PM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
It is worth noting that the ASP.NET MVC Futures assembly is effectively a collection work-in-progress code which is not as rigorously tested as the core MVC assemblies.

In addition, there is a concern that using lambda expressions with ActionLink<T> may be quite a hit on performance as lambda's can be expensive to process. Large pages generating a good number of ActionLink<T>'s with lambdas may see quite a decline in rendering speed.

http://www.codeplex.com/aspnet/WorkItem/View.aspx?WorkItemId=907


Left by Andy Gibson on Feb 03, 2009 11:04 AM

# re: ASP.Net MVC Beta - ActionLink isn't generic anymore
Requesting Gravatar...
I am using yonkly open source code to develop yonkly application locally.
So i am getting error with this code.
----------> Error occuring here <----------

i) <%=Html.ActionLink<ProfileController>(p => p.Edit(), "click here")%> in edit.aspx page

ii) (<%=Html.ActionLink<GroupController>(g => g.New(), "create group")%>) in List.aspx page

iii) <%= ViewData.Model.IsAuthenticated ? Html.ActionLink<GroupController>(g => g.New(), "create group") : "" %> in UserSidebar.aspx page

Error description:


Server Error in '/' Application.
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

Line 136: <h2>
Line 137: My Groups
Line 138: <%= ViewData.Model.IsAuthenticated ? Html.ActionLink<GroupController>(g => g.New(), "create group") : "" %>
Line 139: </h2>
Line 140: <%


Source File: d:\bharathsharma\yonkly\yonkly-18784\Yonkly\Views\Shared\UserSidebar.ascx Line: 138




Please help me... with neat description please
Left by Bharath on Mar 23, 2009 9:19 AM

Your comment:
 (will show your gravatar)


Copyright © Patrice Calvé | Powered by: GeeksWithBlogs.net