I’m having difficulty getting HTML.ActionLink() create correct links.
When I am at
http://localhost:49242/
My options are:
- http://localhost:49242/en-us/PinnedSites ,
- http://localhost:49242/en-us/addons ,
- http://localhost:49242/en-us/trackingprotectionlists
But when I navigate to http://localhost:49242/en-us/PinnedSites my options are:
- http://localhost:49242/en-us/PinnedSites/PinnedSites ,
- http://localhost:49242/en-us/PinnedSites/addons ,
- http://localhost:49242/en-us/PinnedSites/trackingprotectionlists
All of these urls fail, of course.
Here’s my html:
.cshtml (Html / razor)
<li id="nav_pinning">
@Html.ActionLink( "pinned sites", "index", "PinnedSites")</li>
<li id="nav_addons">
@Html.ActionLink("add-ons", "index", "addons")</li>
<li id="nav_control">
@Html.ActionLink("tracking protection lists",
"index",
"trackingprotectionlists",
null,
null)</li>
Global.asax.cs
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("favicon.ico");
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
"Default", // Route name
"{culture}/{controller}/{action}",
new { culture = "en-us",
controller = "Home",
action = "Index",
}
);
}
Where is my problem? Is it possible that /PinnedSites/ is not actually going to the PinnedSitesController?
(And I will be actively watching this, please comment if you want me to try things or provide more code.)
Do you have a HomeController as part of your project? If so you should register the default controller along the lines of:
However, that aside have you tried simply making the Route directly to your PinnedSites controller?