Invoke custom methods

Hi All

I am trying to follow the 'Invoke Custom method' as described in the documentation here...

I have read Blazor - Custom Methods which seems similar except the poster is referring to DataSource Methods rather than ServerMethods.

The ServerMethodsController.cs file did not exist, even after the helpful suggestion to run the application to ensure the files were created etc. So I created it exactly as it shows in the documentation with the 'sum' method.

When setting the click handler of a button, I don't see the same dialog as the documentation shows exactly, 'Invoke Custom Method', only 'Invoke Method'.

I am new here so be gentle, love the concept, love Blazor too. :slight_smile:


This article needs an update badly. The Invoke custom method action doesn't exist in Blazor apps. Neither does ServerMethodsController.cs. The reason is simple - Blazor doesn't need all that. In Blazor apps Radzen has the Invoke method action.

You can add a method to the code-behind of your page - that is the XXX.razor.cs file (use Visual Studio or other text editor to do that). Radzen should guess the type of the method and display it so you can invoke it.

And here is the page code-behind class with the method definitions:

  public partial class PageComponent
    public HttpClient HttpClient { get; set; }

    public async Task<IEnumerable<GitHubIssue>> GetIssues(string repo)
      var message = new HttpRequestMessage(HttpMethod.Get, $"{repo}/issues?state=open&sort=created&direction=desc");
      message.Headers.Add("Accept", "application/vnd.github.v3+json");
      message.Headers.Add("User-Agent", "HttpClient");

      var response = await HttpClient.SendAsync(message);


      var json = await response.Content.ReadAsStringAsync();

      return JsonSerializer.Deserialize<IEnumerable<GitHubIssue>>(json, new JsonSerializerOptions
        PropertyNamingPolicy = JsonNamingPolicy.CamelCase,
        PropertyNameCaseInsensitive = true,

    public int Sum(int x, int y)
        return x + y;

@Korchev, thanks for the super quick response....

What you have written makes a whole lot of sense after taking a step back to think... I was blindly following the docs when I should have been thinking Blazor architecture.

Thanks for the insights and keep up the good work