I need my controller to get a parameter from a URL ( localhost/Check/123456
), where 12346
would be the parameter.
I configured RouteConfig:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
routes.MapRoute("index", "Check/{id}", new { controller = "Check", action = "Indice", id = UrlParameter.Optional });
}
Controller:
public class CheckController : Controller
{
private Check _check;
public ActionResult Index()
{
//_check.NumberOfregistrationUser = Convert.ToInt16(numberOfregistrationUser);
return View();
}
public ActionResult Indice(long numberOfregistrationUser)
{
_check.NumberOfregistrationUser = Convert.ToInt16(numberOfregistrationUser);
return Content(Convert.ToString(_check.NumberOfregistrationUser));
}
}