Question

I'm using ASP.NET MVC 3, along with MvcContrib v 3. MvcContrib has a UrlHelper extension that I'm trying to use in my view. The extension code is as follows:

public static class UrlHelperExtensions
{
    public static string Action<TController>(this UrlHelper urlHelper, Expression<Action<TController>> expression)
    where TController : Controller
    {
        return LinkBuilder.BuildUrlFromExpression<TController>(urlHelper.RequestContext, urlHelper.RouteCollection, expression);
    }
}

However, ASP.NET MVC does not appear to like any syntax I try when using the method in my View.

enter image description here

Était-ce utile?

La solution

Surround it with a @(). You can't use generics in Razor outside a @() block. It would be like:

@(Url.Action<TController>(c => c.YourAction())
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top