티스토리 뷰

728x90
반응형

protected void Application_Error(object sender, EventArgs e)

        {


            


            //Exception exception = Server.GetLastError();

            //Response.Clear();

            //Server.ClearError();


            //RouteData routeData = new RouteData();

            //routeData.Values.Add("controller", "Home");

            //routeData.Values.Add("action", "Test");

            ////routeData.Values.Add("exception", exception);


            //if (exception.GetType() == typeof(HttpException))

            //{

            //    //routeData.Values.Add("statusCode", ((HttpException)exception).GetHttpCode());                

            //}

            //else

            //{

            //    //routeData.Values.Add("statusCode", 500);

            //}


            //IController controller = new HomeController();

            //controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));



            //Exception ex = Server.GetLastError();

            //Exception baseEx = ex.GetBaseException();

            //HttpException httpEx = baseEx as HttpException;


            //if (httpEx != null)

            //{

            //    int eventCode = httpEx.WebEventCode;

            //    HttpContext context = ((HttpApplication)sender).Context;

            //    int result = context.Request.ContentLength;


            //    if (eventCode.Equals(3004))

            //    {

            //        //Exception exception = Server.GetLastError();

            //        Response.Clear();

            //        Server.ClearError();


            //        RouteData routeData = new RouteData();

            //        routeData.Values.Add("controller", "Home");

            //        routeData.Values.Add("action", "Test");

            //        ////routeData.Values.Add("exception", exception);


            //        //if (exception.GetType() == typeof(HttpException))

            //        //{

            //        //    //routeData.Values.Add("statusCode", ((HttpException)exception).GetHttpCode());                

            //        //}

            //        //else

            //        //{

            //        //    //routeData.Values.Add("statusCode", 500);

            //        //}


            //        IController controller = new HomeController();

            //        controller.Execute(new RequestContext(new HttpContextWrapper(Context), routeData));

            //        return;

                    

            //    }

            //}


            //Response.Clear();

            //Server.ClearError();


            //string path = Request.Path;

            //Context.RewritePath(string.Format("~/Home/{0}", "Test"),false);

            //IHttpHandler httpHandler = new MvcHttpHandler();

            //httpHandler.ProcessRequest(Context);

            //Context.RewritePath(path, false);


            //RouteData routeData = new RouteData();

            //routeData.Values.Add("action", "HttpError404");


            //Server.Transfer(this.Request.Url.LocalPath + "/Home/Test", false);                   

            



            // Code that runs when an unhandled error occurs


            // Get the exception object.

            //Exception exc = Server.GetLastError();


            //HttpException ex = Server.GetLastError() as HttpException;

          


            //HttpException httpEx = Server.GetLastError().GetBaseException() as HttpException;

            //int eventCode = httpEx.WebEventCode;


            //HttpContext context = ((HttpApplication)sender).Context;

            //int result = context.Request.ContentLength;


            //Exception message = httpEx.GetBaseException().InnerException;


            //if (httpEx != null)

            //{

            //    int result = httpEx.GetHttpCode();

            //}            

        }

728x90
반응형