I'm trying to get the current page from view in controller, but the code throws the error shown below.
Home controller:
public ActionResult Index()
{
// throws Null
Page = System.Web.HttpContext.Current.Handler as System.Web.UI.Page;
// throws error
Page = (System.Web.UI.Page)System.Web.HttpContext.Current.Handler;
var model = DeviceLoginManager.GetOnlineDevices();
return View(model);
}
Error:
Unable to cast object of type 'System.Web.Mvc.MvcHandler' to type 'System.Web.UI.Page in MVC controller
I need get same page or alternatives for System.Web.UI.Page in ASP.NET MVC.
