Narayan Akhade
Narayan Akhade

Reputation: 2714

ActionLink not outputting correct path

Could you please help me figure out what is wrong with below razor syntax. I am trying to output an anchor tag with a link to MVC action.

Razor Syntax:

@Html.ActionLink("Back to Reports List", "Index", "Reports")

Output in the browser:

<a href="/">Back to Reports List</a>

and not:

<a href="/Reports/Index">Back to Reports List</a>

Any idea?

Upvotes: 0

Views: 95

Answers (1)

P&#233;ter
P&#233;ter

Reputation: 2181

Please show your route config. The url generated based on that. It is possible that your route config start with:

  routes.MapRoute(
      name: "Default",
      url: "{controller}/{action}/{id}",
      defaults: new { controller = "Reports", action = "Index", id = UrlParameter.Optional }
  );

Upvotes: 2

Related Questions