A bit late to the game, but I needed this combined with form validation on the cliend side. So I went this way:
public class ApiFormModel : PageModel
{
[PageRemote(PageHandler = "CheckUri",
HttpMethod = "post",
AdditionalFields = "__RequestVerificationToken,AppId",
ErrorMessage = "Url_Error")]
[BindProperty]
public string? AppRedirectUri { get; set; }
public IActionResult OnPostCheckUri() =>
new JsonResult(Uri.TryCreate(AppRedirectUri, UriKind.Absolute, out _));
}
And in the razor page:
<input type="text" asp-for="AppRedirectUri">
Together with some npm packages you get a nice looking form with client side validation of the uri


ErrorMessage = "please_enter_valid_ftp_url"and ,ErrorMessage = null, i think the one withnullneed to be removed.