Application Error Get Page
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn error displaying the error page application instantiation error more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users
Error Displaying The Error Page Application Instantiation Error Joomla
Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping error displaying the error page application instantiation error table each other. Join them; it only takes a minute: Sign up How to get which page threw an exception to Application_error in aspx up vote 11 down vote favorite 1 I have a general exception handler, Application_error in application_error mvc my global.asax where I'm trying to isolate all the uncaught exceptions on all my many pages. I don't want to use Page_error to catch exception because it's inefficient to call that on so many pages. So where in the exception can I find what page actually caused the exception? c# asp.net exception application-error share|improve this question edited Sep 8 '11 at 15:02 Lars A. Brekken 6,73631926 asked Dec 5 '08 at 16:40 user8456 183312
Mvc Global.asax Application_error
By the way, it's "Global.asax" –Mehrdad Afshari Dec 5 '08 at 16:51 add a comment| 2 Answers 2 active oldest votes up vote 20 down vote accepted HttpContext con = HttpContext.Current; con.Request.Url.ToString() share|improve this answer answered Dec 5 '08 at 16:47 jlew 7,3631949 add a comment| up vote 1 down vote Remember, the page is not (should not) always be the cause of the exception. It could just as easily be coming from another assembly - and if you don't have your logic in your codebehinds, it likely will be coming from another assembly. Don't get me wrong, it is great to know which page, from the aspect of saying X Page caused Y exception in Z assembly. share|improve this answer answered Dec 7 '08 at 13:24 Joseph Ferris 9,48533362 add a comment| Your Answer draft saved draft discarded Sign up or log in Sign up using Google Sign up using Facebook Sign up using Email and Password Post as a guest Name Email Post as a guest Name Email discard By posting your answer, you agree to the privacy policy and terms of service. Not the answer you're looking for? Browse other questions tagged c# asp.net exception application-error or ask your own question. asked 7 years ago viewed 8010 times active 5 years ago Linked 1 How to capture the url of the page that thre
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/Web Forms/how to access current page object when Application_Error from global... how to access current page object when application_error not firing Application_Error from global.asax ? RSS 6 replies Last post Mar 16, 2008 application_error web api 09:35 AM by ad_dc ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered
Exceptionutility
Threads Unresolved Threads Support Options Advanced Search Related Links GuidanceSamplesVideos Reply ad_dc Member 3 Points 79 Posts how to access current page object when Application_Error from global.asax ? Mar 10, http://stackoverflow.com/questions/344440/how-to-get-which-page-threw-an-exception-to-application-error-in-aspx 2008 12:34 PM|ad_dc|LINK hello there , I want to access current page opened when Application_Error event fired , is this possible ? my current Application_Error code is protected void Application_Error(object sender, EventArgs e) { Exception ex = Server.GetLastError(); HttpContext.Current.Session["Error"] = ex.Message; Response.Redirect("~/error.aspx", false); } but I want instate to access the current page to get something from http://forums.asp.net/t/1231422.aspx?how+to+access+current+page+object+when+Application_Error+from+global+asax+ it to save to log file ,[:'(] so anyone can provide help ?????? thanks a lot in advance Reply barryman9000 Participant 767 Points 601 Posts Re: how to access current page object when Application_Error from global.asax ? Mar 10, 2008 12:57 PM|barryman9000|LINK This will give you the name of the page where the error occured. Is that what you're looking for?HttpContext con = HttpContext.Current; con.Request.Url.ToString() "Don't sweat the petty things, and don't pet the sweaty things" - George Carlin Reply ad_dc Member 3 Points 79 Posts Re: how to access current page object when Application_Error from global.asax ? Mar 11, 2008 06:04 AM|ad_dc|LINK Well, thank you but I want to access the Page object itself not it's URL , so any ideas?? Reply ad_dc Member 3 Points 79 Posts Re: how to access current page object when Application_Error from global.asax ? Mar 11, 2008 08:26 AM|ad_dc|LINK Oh , ok I got it worked /*to get a reference to the current pagebeing requested at any point in your application * ,use the following code:*/ System.Web.UI.Page page = System.Web.HttpC
abhishekkumarsingh26 You can get the current request's URL and page like this : void Application_Error(object sender, EventArgs e) { // Code that runs when an unhandled https://abhishekkumarsingh26.wordpress.com/2013/08/06/global-asax-application_error-how-to-get-page-data/ error occurs if (HttpContext.Current != null) { var url = HttpContext.Current.Request.Url; https://community.sitecore.net/developers/f/8/t/244 var page = HttpContext.Current.Handler as System.Web.UI.Page; } } Share this:Click to share on Twitter (Opens in new window)Share on Facebook (Opens in new window)Click to share on LinkedIn (Opens in new window)Click to email (Opens in new window)Click to print (Opens in new window)Like this:Like Loading... error displaying Related This Post was posted in .Net, ASP.Net and tagged ASP.Net, Global.asax. Bookmark the permalink. Leave a Reply Cancel reply Enter your comment here... Fill in your details below or click an icon to log in: Email (required) (Address never made public) Name (required) Website You are commenting using your WordPress.com account. (LogOut/Change) You are commenting using error displaying the your Twitter account. (LogOut/Change) You are commenting using your Facebook account. (LogOut/Change) You are commenting using your Google+ account. (LogOut/Change) Cancel Connecting to %s Notify me of new comments via email. Notify me of new posts via email. Search for: Recent Posts Project Error AssemblyInfo.cs could not beopened How to Allow MySQL Client to Connect to Remote MySQLserver HOW TO INSTALL WINDOWS SERVICE USING COMMANDPROMPT Report Viewer - 404 Error - File or directory notfound How to Create Triggers inMySQL Archives June 2014 May 2014 March 2014 December 2013 October 2013 September 2013 August 2013 July 2013 May 2013 January 2012 October 2011 August 2011 July 2011 June 2011 May 2011 Categories .Net ASP.Net GridView IIS 7.0 Loading Message.. MYSQL Meta Register Log in Entries RSS Comments RSS WordPress.com Blog at WordPress.com. Send to Email Address Your Name Your Email Address Cancel Post was not sent - check your email addresses! Email check failed, please try again Sorry, your blog cannot share posts by email. %d bloggers like this:
exact page from RTE error I use this to get error information to track down bugs....public void Application_Error(object sender, EventArgs args) { var objErr = Server.GetLastError().GetBaseException(); var rawUrl = ""; var rawUrlpath = ""; if (objErr is System.Web.HttpException) { var filePath = Context.Request.FilePath; var url = ((HttpApplication) sender).Context.Request.Url; rawUrl = Sitecore.Context.RawUrl; rawUrlpath = Sitecore.Web.WebUtil.GetLocalPath(rawUrl); Sitecore.Diagnostics.Log.Error("Application_Error:GLOBAL ASAX:HttpException.." + "....URL: " + url + "; FilePath: " + filePath, objErr); Sitecore.Diagnostics.Log.Error("HttpException in " + GetType().ToString() + " processing " + rawUrl + " and Path" + rawUrlpath, System.Web.HttpContext.Current.Server.GetLastError(), this); } else rawUrl = Sitecore.Context.RawUrl; rawUrlpath = Sitecore.Web.WebUtil.GetLocalPath(rawUrl); Sitecore.Diagnostics.Log.Error("Application_Error:GLOBAL ASAX:OtherException..", objErr); Sitecore.Diagnostics.Log.Error("OtherException in " + GetType().ToString() + " processing " + rawUrl + " and Path" + rawUrlpath, System.Web.HttpContext.Current.Server.GetLastError(), this); } I've been seeing an RTE error like this that I'm having trouble tracking down... 5880 09:45:40 ERROR Application_Error:GLOBAL ASAX:HttpException......URL: wcmstage.smu.edu/.../Rich Text Editor/~/media/sitecore_media.ashx/sitecore/shell/Controls/Rich Text Editor/~/media/316FEE124E084BB58EFF46C533E8E04D.ashx?la=en; FilePath: /sitecore/shell/Controls/Rich Text Editor/~/media/sitecore_media.ashx5880 09:45:40 ERROR HttpException in ASP.global_asax processing /sitecore/shell/Controls/Rich Text Editor/~/media/316FEE124E084BB58EFF46C533E8E04D.ashx?la=en and Path/sitecore/shell/Controls/Rich Text Editor/~/media/316FEE124E084BB58EFF46C533E8E04D.ashxException: System.Web.HttpExceptionMessage: Error executing child request for /sitecore/login.Source: System.Web at System.Web.HttpServerUtility.ExecuteInternal(IHttpHandler handler, TextWriter writer, Boolean preserveForm, Boolean setPreviousPage, VirtualPath path, VirtualPath filePath, String physPath, Exception error, String queryStringOverride) at System.Web.HttpServerUtility.Execute(String path, TextWriter writer, Boolean preserveFor