my code is below:
public class Lib
{
public int ID { get; set; }
[Required]
[PageRemote(PageHandler = "IsKeyExists", HttpMethod = "Get")]
public string Key { get; set; }
}
in the Create page model:
public async Task<IActionResult> OnGetIsKeyExistsAsync(string key)
{
var query = _context.Lib.Any(l => l.Key == key);
if (query)
{
return new JsonResult($"Key {key} exists");
}
return new JsonResult(true);
}
When I Debug the code, OnGetIsKeyExistsAsync
always get the parameter key of value null.
I find the request in browe is:
https://localhost:44377/Libs/Create?handler=IsKeyExists&Lib.Key=xx
I test with PostMan
, and modify the parameter name with Key, and everything runs ok.
https://localhost:44377/Libs/Create?handler=IsKeyExists&Key=xx
I don't want to modify my page model to bind another string value,and how to make it work with Lib.Key
?
Maybe this question is not about remote page, only relation to razor
page or asp.net core
.