Custom Error Page In Global.asax
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 more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Custom Error using Global.asax asp.net up vote 3 down vote favorite I made an error; the page directs users in case of error in any applications within the website. I made Global.asax rather than using Webconfig. My question is : Is it possible to redirect user from Global.asax for those statusCodes "401", "404" and "500" in case of error rather than using Webconfig ? In other words, using Global.aspx rather than Webconfig !? I am just curious to know. Thank you c# asp.net share|improve this question edited Dec 29 '14 at 13:08 SandyShores 4811519 asked Dec 29 '14 at 12:19 Dodi 7416 It is possible, however I really don't see any value added...stackoverflow.com/questions/14822435/… –gustavodidomenico Dec 29 '14 at 12:23 using web.config is better just search on google for
resources Windows Server 2012 resources Programs MSDN subscriptions Overview Benefits Administrators Students Microsoft Imagine Microsoft Student Partners ISV Startups TechRewards Events Community Magazine Forums Blogs Channel 9 Documentation APIs and reference Dev centers Retired content Samples We’re sorry. The content you requested has been removed. You’ll be auto redirected in 1 second. MSDN Library MSDN Library MSDN Library MSDN Library Design Tools Development Tools and Languages Mobile and Embedded http://stackoverflow.com/questions/27688759/custom-error-using-global-asax-asp-net Development .NET Development Office development Online Services Open Specifications patterns & practices Servers and Enterprise Development Speech Technologies Web Development Windows Desktop App Development TOC Collapse the table of content Expand the table of content This documentation is archived and is not being maintained. This documentation is archived and is not https://msdn.microsoft.com/en-us/library/bb397417.aspx being maintained. Complete Example for Error Handlers Other Versions Visual Studio 2010 .NET Framework 4 Visual Studio 2008 This code example includes elements for both page-level and application-level exception handling. Code Example Files The example consists of the following files: Web.config Global.asax Default.aspx ExceptionUtility (to be put in the App_Code folder) GenericErrorPage.aspx HttpErrorPage.aspx Http404ErrorPage.aspx DefaultRedirectErrorPage.aspx Web.config The following example shows the Web.config file. The customErrors section specifies how to handle errors that occur with file types that are mapped to ASP.NET, such as .aspx, .asmx, and .ashx files. (In IIS 6.0 and in IIS 7.0 in classic mode, static content files such as .html and .jpg files are not mapped to ASP.NET.) The settings in the example customErrors section cause any unhandled HTTP 404 (file not found) errors to be directed to the Http404ErrorPage.aspx file. These HTTP 404 errors would occur if a request were made for an .asp
ASP.NET Community Standup Forums Help Home/ASP.NET Forums/General ASP.NET/State Management/How to pass exception details from global.asax http://forums.asp.net/t/1405077.aspx?How+to+pass+exception+details+from+global+asax+to+custom+error+page to custom error page How to pass exception details from global.asax to custom error page [Answered]RSS 7 replies Last post Sep 27, 2011 10:51 AM by Roblem ‹ Previous Thread|Next Thread › Print Share Twitter Facebook Email Shortcuts Active Threads Unanswered Threads Unresolved Threads Support Options Advanced Search Reply custom error sreeram gull... None 0 Points 4 Posts How to pass exception details from global.asax to custom error page Apr 01, 2009 10:43 AM|sreeram gullapalli|LINK Hi, I am capturing the exception from global.asax(with out using try...catch block). So these error become unhandled exceptions. I will capture the exception using server.GetlastError() method. custom error page Now I want to store it in session and get it access in the custom error page(I need to customise the error display).But i could not able to access the session values in custom error page. Can pl suggest me how to get error details in custom error page. Is there anyway to get the exception details without using session(Without using queystring). How to get the timestamp of the exception(with using exception instance(without using datetime.now))? Below i amenclosing the code snippet. In Global.asax:protected void Application_Error(Object sender, EventArgs e) { Exception err = Server.GetLastError();
Session["Message"] = err.Message.ToString(); Session["ExceptionType"] = err.GetType().ToString(); Session["Source"] = err.Source.ToString(); Session["TargetSite"] = err.TargetSite.ToString(); Session["Timestamp"] = DateTime.Now.ToString(); if (err is HttpException && err.InnerException != null) { err = err.InnerException; //Avoid the Unhandled Exception wrapper which is meaningless } ExceptionManager.Publish(err); } In Error_Message.aspx page: protected void Page_Load(object sender, System.EventArgs e) { if (!IsPostBack) { StateManager.TrkObjLicPlate = st