【发布时间】:2020-10-31 06:18:26
【问题描述】:
当用户点击它时,我有下面的链接,它应该是加载当前区域中的文章视图。 图片
但我已经检查了我的路由配置和管理区域,并且我也使用了命名空间。 在我的路由配置中 在我的管理区域
我不知道是什么问题,我使用了命名空间,但它不起作用。
当我点击这个链接<a href="/Article/Details/2">
我得到了错误,但我的路由配置像这样
在我的路由配置中:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "IdentitySample.Controllers" }
);
在管理区域配置中:
public override void RegisterArea(AreaRegistrationContext context)
{
context.MapRoute(
"Administrator_default",
"Administrator/{controller}/{action}/{id}",
new { controller = "Home", action = "Index", id = UrlParameter.Optional },
new[] { "tadvinhesab.Areas.Administrator.Controllers" }
);
}
我最终得到了这个链接
<a href="@Url.Action("Details", "Article", new { Area = "IdentitySample",id = @article.id }, "https")">
但是Area = "IdentitySample" 导致当我放入新数组时链接不起作用。
在另一个镜头中,我以这种方式改变了它
<a href="@Url.Action("Details", "Article", new { Area = "", id = @article.id})" class="myCssClass">link text</a>
但我的问题还是一样
【问题讨论】:
-
复制粘贴代码,请勿截图,我们很难通过。
标签: c# asp.net-mvc namespaces