Solved

Application_Error in Global.asax not firing

Posted on 2009-07-13
11
3,168 Views
Last Modified: 2013-11-08
The Application_Error fires in development, but not on production server. I have stripped out everything I can think of to eliminate other possible errors. With the code below in development I get a page with "Found ERROR" on it. In production I get the default ASP.NET error page with the stack trace. I have been searching for an answer for a while, any help will be appreciated.
Index.aspx.cs:

        protected void Page_Load(object sender, EventArgs e)

        {

            throw new Exception("ERROR");

        }

 

Global.asax.cs:

        protected void Application_Error(object sender, EventArgs e)

        {

            Response.Write("Found ERROR");

            Server.ClearError();

        }

Open in new window

0
Comment
Question by:hwsitservices
  • 6
  • 4
11 Comments
 
LVL 15

Expert Comment

by:jinal
Comment Utility
Please check web.config on production server.
1. What is custom error mode ?
2. Is that global.asax works on production server ?
 
0
 

Author Comment

by:hwsitservices
Comment Utility
I set customErrors mode="Off", because I want to see if Response.Write("Found ERROR"); in the Application_Error event gets hit, it does not.
0
 
LVL 22

Expert Comment

by:prairiedog
Comment Utility
Make sure the ASP.NET runtime version on the production server is correctly set.
0
 

Author Comment

by:hwsitservices
Comment Utility
Yes, it is set to 2.0.50727 same as my development server.
0
 
LVL 22

Expert Comment

by:prairiedog
Comment Utility
1. Can yo post your web.config file?

2. What does the stack trace say?


0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

Author Comment

by:hwsitservices
Comment Utility
My Web.confid is below with slight changes for security reasons.

STACK TRACE (my forced exception):
[Exception: ERROR]
   ITU.Index.Page_Load(Object sender, EventArgs e) in C:\Documents and Settings\Ed\My Documents\Visual Studio 2008\Projects\ITU\Index.aspx.cs:25
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +14
   System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +35
   System.Web.UI.Control.OnLoad(EventArgs e) +99
   System.Web.UI.Control.LoadRecursive() +50
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +627

Why does the first line give the path to the file as it where on my local machine? This is the stack trace from the production server.
 

<?xml version="1.0"?>

<configuration>

	<configSections>

		<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

			<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

				<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

				<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">

					<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="Everywhere"/>

					<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

					<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

					<section name="roleService" type="System.Web.Configuration.ScriptingRoleServiceSection, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" allowDefinition="MachineToApplication"/>

				</sectionGroup>

			</sectionGroup>

		</sectionGroup>

	</configSections>

  <appSettings>

  </appSettings>

	<connectionStrings>

	</connectionStrings>

	<system.web>

    <machineKey validationKey='XXXXXXXXXXX' 

decryptionKey='XXXXXX' validation='SHA1'/>

    <!-- 

            Set compilation debug="true" to insert debugging 

            symbols into the compiled page. Because this 

            affects performance, set this value to true only 

            during development.

        -->

		<compilation debug="true">

			<assemblies>

				<add assembly="System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

				<add assembly="System.Data.DataSetExtensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

				<add assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

				<add assembly="System.Xml.Linq, Version=3.5.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>

				<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>

				<add assembly="System.Web.Extensions.Design, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

				<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/></assemblies>

		</compilation>

		<!--

            The <authentication> section enables configuration 

            of the security authentication mode used by 

            ASP.NET to identify an incoming user. 

        -->

    <authentication mode="Windows"/>
 

    <customErrors mode="Off" defaultRedirect="Error.aspx">

      <error statusCode="404" redirect="ErrorPageNotFound.aspx"/>

    </customErrors>

		<!--customErrors mode="Off"></customErrors-->

		<!--

            The <customErrors> section enables configuration 

            of what to do if/when an unhandled error occurs 

            during the execution of a request. Specifically, 

            it enables developers to configure html error pages 

            to be displayed in place of a error stack trace.
 

        <customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">

            <error statusCode="403" redirect="NoAccess.htm" />

            <error statusCode="404" redirect="FileNotFound.htm" />

        </customErrors>

        -->

		<pages>

			<controls>

				<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

				<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

			</controls>

		</pages>

		<httpHandlers>

			<remove verb="*" path="*.asmx"/>

			<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

			<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

			<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" validate="false"/>

		</httpHandlers>

		<httpModules>

			<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

		</httpModules>

	</system.web>

	<system.codedom>

		<compilers>

			<compiler language="c#;cs;csharp" extension=".cs" warningLevel="4" type="Microsoft.CSharp.CSharpCodeProvider, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">

				<providerOption name="CompilerVersion" value="v3.5"/>

				<providerOption name="WarnAsError" value="false"/>

			</compiler>

		</compilers>

	</system.codedom>

	<!-- 

        The system.webServer section is required for running ASP.NET AJAX under Internet

        Information Services 7.0.  It is not necessary for previous version of IIS.

    -->

	<system.webServer>

		<validation validateIntegratedModeConfiguration="false"/>

		<modules>

			<remove name="ScriptModule"/>

			<add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

		</modules>

		<handlers>

			<remove name="WebServiceHandlerFactory-Integrated"/>

			<remove name="ScriptHandlerFactory"/>

			<remove name="ScriptHandlerFactoryAppServices"/>

			<remove name="ScriptResource"/>

			<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

			<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

			<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>

		</handlers>

	</system.webServer>

	<runtime>

		<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

			<dependentAssembly>

				<assemblyIdentity name="System.Web.Extensions" publicKeyToken="31bf3856ad364e35"/>

				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

			</dependentAssembly>

			<dependentAssembly>

				<assemblyIdentity name="System.Web.Extensions.Design" publicKeyToken="31bf3856ad364e35"/>

				<bindingRedirect oldVersion="1.0.0.0-1.1.0.0" newVersion="3.5.0.0"/>

			</dependentAssembly>

		</assemblyBinding>

	</runtime>

</configuration>

Open in new window

0
 
LVL 22

Expert Comment

by:prairiedog
Comment Utility
How did you deploy your application to the production server?
0
 

Author Comment

by:hwsitservices
Comment Utility
I publish it to a folder on my local machine the ftp those files to production server. This is how I have been deploying for two years.

In my Stack trace above do you have any idea why the first line gives the path to the file as it where on my local machine, not the production server?
0
 
LVL 22

Expert Comment

by:prairiedog
Comment Utility
It might sound very silly, but did you build your application before publishing it? You may want to try "Clean" solution, then Rebuild it, then Publish it.
0
 

Author Comment

by:hwsitservices
Comment Utility
Tried that and get the same result. The Application_Error event still does not fire in Production.
0
 

Accepted Solution

by:
hwsitservices earned 0 total points
Comment Utility
I found the answer here http://www.velocityreviews.com/forums/t300533-globalasax-not-firing.html. Needed to delete PrecompiledApp.config
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

This article describes relatively difficult and non-obvious issues that are likely to arise when creating COM class in Visual Studio and deploying it by professional MSI-authoring tools. It is assumed that the reader is already familiar with the cla…
Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now