【发布时间】:2020-04-15 06:02:02
【问题描述】:
我的代码如下:
public class Lib
{
public int ID { get; set; }
[Required]
[PageRemote(PageHandler = "IsKeyExists", HttpMethod = "Get")]
public string Key { get; set; }
}
在创建页面模型中:
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);
}
当我调试代码时,OnGetIsKeyExistsAsync 总是获取值为 null 的参数键。
我发现 browe 中的请求是:
https://localhost:44377/Libs/Create?handler=IsKeyExists&Lib.Key=xx
我用PostMan测试,用Key修改参数名,一切正常。
https://localhost:44377/Libs/Create?handler=IsKeyExists&Key=xx
我不想修改我的页面模型来绑定另一个字符串值,以及如何使它与 Lib.Key 一起工作?
也许这个问题与远程页面无关,仅与 razor 页面或 asp.net 核心有关。
【问题讨论】:
-
您的剃须刀页面浏览量如何?
标签: asp.net-core-mvc razor-pages