asp.net-core - asp.net核心路由参数始终为空
问题描述
我有一个 actionresult 方法,它接受一个字符串作为参数,但是每当我使用 url 查询该方法时,该参数始终为空。
abc
是路由中id的值。但是当我查看堆栈跟踪时,我看不到方法接受任何值。
http://localhost:47268/admin/AllQuarterEvent/abc
public IActionResult AllQuarterEventByMap(string map)
{
return View(_staffMethods.GetQuarterEventsByMap(map));
}
解决方案
请尝试此解决方案:
[HttpGet("admin/AllQuarterEventByMap/{map}")]
public IActionResult AllQuarterEventByMap([fromRoute] string map)
{
return View(_staffMethods.GetQuarterEventsByMap(map));
}
推荐阅读
- python - 尝试导出 YOLO 训练样本时,Labelimg 崩溃
- file - 自动文件上传的间歇性问题
- python - Pygame 没有在树莓派上播放声音
- c# - C# ASP.Net 中的全局对象 - 回读时始终为空
- postgresql - 为什么在 postgresql 中成功创建索引后没有建立索引?
- java - Java:从超类继承时如何定义equals和hashCode?
- reactjs - React - 类似列表的状态正在失去价值
- c# - 在 C# 中使用继承时无法打印数组的值
- dart - 按字段列出到嵌套列表
- csv - AWS Glue write_dynamic_frame_from_options 遇到架构异常