سؤال

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

هل كانت مفيدة؟

المحلول

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

@(Url.Action<TController>(c => c.YourAction())
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top