Why does the 'as' keyword work while the () cast does not.
- by Mausimo
//always works, returning a valid object into _page
_page = _httpContext.Handler as System.Web.UI.Page;
//Fails throwing the exception : Unable to cast object of type 'System.Web.DefaultHttpHandler' to type 'System.Web.UI.Page'
_page = (System.Web.UI.Page)_httpContext.Handler;
I would like to know why this happens?