c# - Cannot render correct URL for my MVC Areas -
just starting delve route areas. i'm attempting basic stuff first before fancy. when type physical route address bar works great. however, when try use @url.action or @html.actionlink create link mvc cannot figure out how calculate correct route.
typing works: so, know routes setup correctly...
http://localhost:51515/intro/tutorials/one my controller looks like:
again, resolves correctly when type address bar...
[routearea("intro")] [routeprefix("tutorials")] [route("{action}")] public class introtutorialscontroller : controller { public actionresult one() { var path = @"~/views/tutorials/intro/one.cshtml"; return view(path); } } my sad attempts @ url:
obviously, problem here...
@html.actionlink("intro", "one", "tutorials", new { area = "intro" }, null) <a href="@url.action("one", "tutorials", new { area = "intro" })">one</a> these resolve nothing and/or nonsense...
on side-note:
if hand-type url's link...they work.
for example:
- href="/intro/tutorials/one"
sorry have answer own question...
apparently, html.actionlink , url.action commands not consider attribute prefixing may have put atop controllers. such, must still input action & controller name in normal format...then...add-in area.
this worked me...
@url.action("one", "introtutorials", new { area = "intro" })
Comments
Post a Comment