c# - html 路由值未传递到 url/控制器
问题描述
标题基本概括了所有内容
这是控制器动作方法
public async Task<IActionResult> Index(string Name, string isType)
{
if (isType != null)
{
RedirectToAction("Index","ProductsController", new { type=Name });
}
var categories = await _context.Categories.
Where(c => (c.ParentCategory == Name)).ToListAsync();
return View(categories);
}
这是试图路由到控制器的 html
@* @("~/img/"+item.CategoryName+".jpg") *@
<a asp-action="index" asp-route-name="@item.CategoryName" asp-route-isType="@item.IsType">
<text>@item.CategoryName</text>
</a>|
模型定义
public class Category
{
public int CategoryID { get; set; }
public string CategoryName { get; set; }
public string Imgfilepath { get; set; }
public string ParentCategory { get; set; }
public string IsType { get; set; }
}
对我来说奇怪的是 item.CategoryName 得到了很好的通过,但是 isType 属性似乎没有通过,因为当我签入调试器时它总是为空。
解决方案
推荐阅读
- android - 将更多数组字段上传到 Firestore
- r - Groupby 和 grep 值以填充 dplyr 中的一列
- multithreading - 在 tcl 线程中使用包
- javascript - 如何在 EventEmitter 的 on('change') 函数中使用钩子设置状态?
- python - 我们可以在不使用 R 或 Python 提取的情况下打开 .gz 格式的数据集吗?
- python - InlineKeyboard 使用请求电报库
- angular - Microsoft Edge 浏览器以兼容模式打开 Angular 应用程序:IE 11
- php - Laravel Passport 没有身份验证
- python - 刮掉没有类名的 Span 标签,并且不会出现在所有元素中
- java - 在二维数组中选择最小 ID 时删除重复行