开发者

Strongly typed links in ASP.NET MVC 2.0 beta

开发者 https://www.devze.com 2022-12-12 22:13 出处:网络
With ASP.NET MVC 1.0 I always have bee开发者_开发问答n able to generate strongly typed links in my Views using a lambda function:

With ASP.NET MVC 1.0 I always have bee开发者_开发问答n able to generate strongly typed links in my Views using a lambda function:

Html.BuildUrlFromExpression<TController>(c => c.Action(arg));

I'm now upgrading to ASP.NET MVC 2.0 beta and I can't find any strongly typed extension for the HtmlHelper (nor the UrlHelper in fact). Have they been replaced by some other method? Is there a new way of building links to controller actions?

I'd hate to go back to using strings in my views.


The strongly-typed URL generation helpers are part of the MVC Futures binary, not the MVC core binary itself. You can download a version of MVC Futures that works with MVC 2 Beta from CodePlex.


It takes one line to implement you own extension with same functionality. I actually do it even in MVC v1, because Url.Href<> is shorter ;-) You can copy code from MVC sources for this.

0

精彩评论

暂无评论...
验证码 换一张
取 消