User problem using HtmlHelper extension method in asp.net mvc razor

I converted my classic asp.net mvc views to a razor. The view uses the extension method (it has overloads) of HtmlHelper:

@Html.CustomAction<AccountController, LogOnModel>("displayText", x => x.Register())

And the signature of CustomAction:

public static HtmlString CustomAction<TController, TModel>(this HtmlHelper<TModel> view, string displayText, Expression<Func<TController, object>> where TController : Controller

I also enabled view compilation during build (via the .proj file). When I create a project, I get these errors pointing to this line:

  • Argument 1: cannot be converted from the 'method group' of 'System.Web.WebPages.HelperResult'

  • The best overloaded method match for 'System.Web.WebPages.WebPageExecutingBase.Write (System.Web.WebPages.HelperResult)' has some invalid arguments

What is the cause of these errors? How can I fix it?

+3
source share
1

Razor < HTML. Html.CustomAction .

, :

@(Html.CustomAction<AccountController, LogOnModel>("displayText", x => x.Register()))
+6

Source: https://habr.com/ru/post/1793445/


All Articles