gpt4 book ai didi

c# - 发现多种类型在不同区域匹配

转载 作者:行者123 更新时间:2023-12-04 16:55:29 25 4
gpt4 key购买 nike

当用户点击它时我有波纹管链接,它应该是加载当前区域中的文章 View 。
图片
enter image description here
但是当我点击这个链接时,我收到了这个错误
enter image description here
但我检查了我的 routeconfig 和我的管理区域,我也使用了命名空间。
在我的路由配置中
enter image description here
在我的管理区域
enter image description here
我不知道是什么问题,我使用了命名空间,但它不起作用。
当我点击这个链接时 <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>但我的问题还是一样

最佳答案

看起来您忘记更改命名空间:

namespaces: new[] { "IdentitySample.Controllers" }
你应该把它改成这样:
namespaces: new[] { "tadvinhesab.Controllers" }
同样在此链接中,您可以看到许多其他可能的解决方案来解决这个问题:
Multiple types were found that match the controller named 'Home'

关于c# - 发现多种类型在不同区域匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62835431/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com