In my routing I have
routes.MapRoute(
name: "ctrl",
url: "ctrl/{target_name}",
defaults: new { controller = "ctrl", action = "TheAction" }
);
How do I access target_name? I tried ViewBag.target_name, I Googled and found many pages say RouteData.Values but I get a compile error
CS0120: An object reference is required for the non-static field, method, or property 'System.Web.Routing.RouteData.Values.get'
So I end up doing
public ActionResult TheAction(string target_name) { ViewBag.target_name = target_name; return View(); }
which appears to be very wrong (because it seems stupid)
How do I access target_name in my view?