Preciso que meu controller obtenha um parâmetro de uma URL (localhost/Check/123456
), onde 12346
seria o parâmetro.
Configurei o 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));
}
}
long
e depois convertê-lo parashort
?