# Invoke custom methods

**URL:** <https://forum.radzen.com/t/invoke-custom-methods/1741>\
**Category:** Blazor Server\
**Created:** [October 10, 2019, 2:14pm UTC](https://forum.radzen.com/t/invoke-custom-methods/1741 "2019-10-10T14:14:58Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BowlerHat](https://forum.radzen.com/user_avatar/forum.radzen.com/bowlerhat/32/1781_2.png) [@BowlerHat](https://forum.radzen.com/u/BowlerHat)\
**Post date:** [October 10, 2019, 2:14pm UTC](https://forum.radzen.com/t/invoke-custom-methods/1741/1 "2019-10-10T14:14:58Z")

</div>

Hi All

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

> **[Invoke custom method](https://www.radzen.com/documentation/invoke-custom-method/)**
>
> Implement custom methods in C# or VB and invoke them in Radzen

I have read [Blazor - Custom Methods](http://forum.radzen.com/t/blazor-custom-methods/1271) 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. 🙂

Mark

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [October 10, 2019, 2:45pm UTC](https://forum.radzen.com/t/invoke-custom-methods/1741/2 "2019-10-10T14:45:55Z")

</div>

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.

 ![image](https://forum.radzen.com/uploads/default/original/2X/7/771e2e863d2dba1f3d19eb9e47e753dca1bc3f50.png)

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

```cs
  public partial class PageComponent
  {
    [Inject]
    public HttpClient HttpClient { get; set; }

    public async Task<IEnumerable<GitHubIssue>> GetIssues(string repo)
    {
      var message = new HttpRequestMessage(HttpMethod.Get, $"https://api.github.com/repos/{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);

      response.EnsureSuccessStatusCode();

      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;
    }
  }

```

---

<div class="post-metadata">

**Author:** ![BowlerHat](https://forum.radzen.com/user_avatar/forum.radzen.com/bowlerhat/32/1781_2.png) [@BowlerHat](https://forum.radzen.com/u/BowlerHat)\
**Post date:** [October 10, 2019, 2:50pm UTC](https://forum.radzen.com/t/invoke-custom-methods/1741/3 "2019-10-10T14:50:05Z")

</div>

@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

🙂

Mark
