区域在 Asp dot net Core 6 中不工作

问题描述 投票:0回答:1

enter image description here

enter image description here

enter image description here

https://localhost:7082/EmpList/EmployeeData/Index
当请求通过“return View()”时,它无法识别视图页面,我希望显示“localhost:7082”,然后直接显示索引页面。但我不工作

routes view area core
1个回答
0
投票

我看过你的图片,发现你已经用 EmpList 硬编码了端点。相反,你应该执行以下操作

endpoints.MapControllerRoute("area", "{area:exists}/{controller=Home}/{action=Index}/{id?}");

然后在控制器中,您需要指定如下区域。这种单一配置适用于多个区域

[Area("Products")]
public class ProductController: Controller
{
}


[Area("EmpList")]
public class EmployeeDataController: Controller
{
}
 
© www.soinside.com 2019 - 2024. All rights reserved.