I want to get the id of my current url and use it in a controller.
http://localhost:14160/?id=69
this Request.RequestContext.RouteData.Values["id"]
is returning null value.
Any ideas?
controller:
public class HomeController : Controller
{
public ActionResult Index(int? id = null)
{
ViewBag.ID = id;
return View();
}
}
controller i want to get the id at:
public class FacilityAddController : Controller
{
public ActionResult GetID()
{
var id= Request.RequestContext.RouteData.Values["id"];
return Json(id, JsonRequestBehavior .AllowGet);
}
}