Reputation:
I have bellow link when the user click on it ,it should be load Article view that is in current area.
picture
But when I click on this link I get this error
but I've checked my routeconfig and my admin area and I have used namespases as well.
In my routeconfig
In my Admin area
I can not figure out what problem is ,I've used namespaces but it doesn't work.
when I click on this link <a href="/Article/Details/2">
I get the Error but my route config like these
In my routeconfig:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional },
namespaces: new[] { "IdentitySample.Controllers" }
);
And in Admin area config:
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" }
);
}
and I ended up with this link
<a href="@Url.Action("Details", "Article", new { Area = "IdentitySample",id = @article.id }, "https")">
but Area = "IdentitySample"
cause the link dose not work when i put in new array.
And in another shot I changed it this way
<a href="@Url.Action("Details", "Article", new { Area = "", id = @article.id})" class="myCssClass">link text</a>
but my problem in still the same
Upvotes: 1
Views: 229
Reputation:
After a few hours working around, I finally realized that I use identity sample project that default namespace was identitySmaple
but in some sections of my project I used my own namespace with a different names from identitySmaple
that causes this weird problem.
with the help of (Ctrl+Shift+H), I replaced all identitySmaples
to my namespace then It works properly.
Upvotes: 0
Reputation: 5275
looks like you forgot to change the namespace:
namespaces: new[] { "IdentitySample.Controllers" }
you should change it to something like this:
namespaces: new[] { "tadvinhesab.Controllers" }
also in this link, you can see a lot of other possible solutions to solve this:
Multiple types were found that match the controller named 'Home'
Upvotes: 0