0

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?

Narayan Akhade
  • 2,694
  • 3
  • 21
  • 30

1 Answers1

2

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 }
  );
Péter
  • 2,161
  • 3
  • 21
  • 30
  • Thanks Peter. Spot on - that was the problem. I didn't know ActionLink checks the route config to output the paths! many thanks – Narayan Akhade Feb 25 '14 at 10:06