In the auto-generated site.js file of the ASP.NET Core Razor Pages project in Visual Studio, I am trying to call with Ajax

```
    $.ajax
        ({
            type: "POST",
            url: "",
            data: "asdsad",
            dataType: "text",
            success: function (result) {
                alert(result);
            },
            error: function (status, ex) {
                alert("Error Code: Status: " + status + " Ex: " + ex);
            }
        });

```

a C# function. My project tree looks like this:

[![ASP.NET Core Razor Pages project tree](https://i.stack.imgur.com/VyMTa.png)](https://i.stack.imgur.com/VyMTa.png)

The `builder.cshtml.cs` file was also auto-generated by Visual Studio when I added the `builder.cshtml` page. Inside my `builder.cshtml.cs` there is this code:

```
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.RazorPages;

namespace MyProjectName.Pages
{
    public class Index1Model : PageModel
    {
        public string Message { get; set; } = "Initial Request";
        public void OnGet()
        {
            Message = "Test1";
        }

        public void HelloFunc()
        {
            Message = "BuilderJob";
        }
    }
}

```

I added the function `HelloFunc()` and the `Message` variable. I don't understand after going through the [ASP.NET Core documentation by Microsoft](https://learn.microsoft.com/en-us/aspnet/core/getting-started/?view=aspnetcore-2.2&tabs=windows) what is the "url" to call the `HelloFunc` from my Ajax code. It is not `/builder/HelloFunc` (doesn't work). How do I access this `HelloFunc` from my Ajax call?

The answer is to change `HelloFunc` to `OnPostHelloFunc()` and use this `url: /builder?handler=HelloFunc` and if you are just testing and not using a validation token, to insert [IgnoreAntiforgeryToken(Order = 1001)] as instructed here [test .net core 2 page using Postman return 400 bad request](https://stackoverflow.com/questions/47453401/test-net-core-2-page-using-postman-return-400-bad-request)