+2010-04-21 Marek Habersack <mhabersack@novell.com>
+
+ * HttpApplication.cs: update to fix for bug #572469 - ProcessError
+ clears the error after handler return only if stop_processing is
+ true. Also, stop_processing is never set before calling ProcessError
+
2010-04-02 Marek Habersack <mhabersack@novell.com>
* HttpException.cs: handle situations when current exception is an
if (eh != null){
try {
eh (this, EventArgs.Empty);
- context.ClearError ();
+ if (stop_processing)
+ context.ClearError ();
} catch (ThreadAbortException taex){
context.ClearError ();
if (FlagEnd.Value == taex.ExceptionState || HttpRuntime.DomainUnloading)
} catch (ThreadAbortException taex) {
object obj = taex.ExceptionState;
Thread.ResetAbort ();
- stop_processing = true;
if (obj is StepTimeout)
ProcessError (new HttpException ("The request timed out."));
else {
if (FlagEnd.Value != obj && !HttpRuntime.DomainUnloading)
context.AddError (taex);
}
-
+
+ stop_processing = true;
PipelineDone ();
} catch (Exception e) {
- stop_processing = true;
ProcessError (e);
+ stop_processing = true;
PipelineDone ();
}
}
namespace StandAloneTests.Unhandled_Exception_Global_Asax
{
- [TestCase ("Unhandled_Exception_Global_Asax 01", "Unhandled exception handled in Global.asax, test 01")]
+ [TestCase ("Unhandled_Exception_Global_Asax 01", "Unhandled exception not handled in Global.asax, test 01")]
public sealed class Unhandled_Exception_Global_Asax_01 : ITestCase
{
public string PhysicalPath {
void Default_Aspx (string result, TestRunItem runItem)
{
- string originalHtml = @"<strong>Application error handled</strong>";
+ string originalHtml1 = @"[System.Web.HttpUnhandledException]: Exception of type 'System.Web.HttpUnhandledException' was thrown.";
+ string originalHtml2 = @"[System.InvalidOperationException]: test";
- Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
+ Assert.IsTrue (result.IndexOf (originalHtml1) != -1, "#A1");
+ Assert.IsTrue (result.IndexOf (originalHtml2) != -1, "#A2");
}
}
Assert.IsTrue (result.IndexOf (originalHtml) != -1, "#A1");
}
}
+
+ [TestCase ("Unhandled_Exception_Global_Asax 03", "Unhandled exception handled in Global.asax, test 03")]
+ public sealed class Unhandled_Exception_Global_Asax_03 : ITestCase
+ {
+ public string PhysicalPath {
+ get {
+ return Path.Combine (
+ Consts.BasePhysicalDir,
+ Path.Combine ("Unhandled_Exception_Global_Asax", "test_03")
+ );
+ }
+ }
+
+ public string VirtualPath {
+ get { return "/"; }
+ }
+
+ public bool SetUp (List <TestRunItem> runItems)
+ {
+ runItems.Add (new TestRunItem ("/default.aspx", Default_Aspx));
+
+ return true;
+ }
+
+ void Default_Aspx (string result, TestRunItem runItem)
+ {
+ string originalHtml = @"<strong>Application error handled</strong>";
+
+ Helpers.ExtractAndCompareCodeFromHtml (result, originalHtml, "#A1");
+ }
+ }
+
+ [TestCase ("Unhandled_Exception_Global_Asax 04", "Unhandled exception handled in Global.asax, test 04")]
+ public sealed class Unhandled_Exception_Global_Asax_04 : ITestCase
+ {
+ public string PhysicalPath {
+ get {
+ return Path.Combine (
+ Consts.BasePhysicalDir,
+ Path.Combine ("Unhandled_Exception_Global_Asax", "test_04")
+ );
+ }
+ }
+
+ public string VirtualPath {
+ get { return "/"; }
+ }
+
+ public bool SetUp (List <TestRunItem> runItems)
+ {
+ runItems.Add (new TestRunItem ("/default.aspx", Default_Aspx));
+
+ return true;
+ }
+
+ void Default_Aspx (string result, TestRunItem runItem)
+ {
+ string originalHtml = @"<h2>Object moved to <a href=""http://google.com/"">here</a></h2>";
+
+ Assert.IsTrue (result.IndexOf (originalHtml) != -1, "#A1");
+ }
+ }
}
--- /dev/null
+<%@ Page Language="C#" %>
+<script runat="server">
+ void Page_Load (object sender, EventArgs e)
+ {
+ throw new InvalidOperationException ("test");
+ }
+</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head runat="server">
+ <title>Default</title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ </form>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ Application CodeFile="global.asax.cs" Inherits="TestWebApp.Global" %>
--- /dev/null
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Web;
+using System.Web.SessionState;
+
+namespace TestWebApp
+{
+ public partial class Global : System.Web.HttpApplication
+ {
+ protected virtual void Application_Error (Object sender, EventArgs e)
+ {
+ HttpResponse response = Response;
+
+ if (response != null) {
+ string begin = (string)AppDomain.CurrentDomain.GetData ("BEGIN_CODE_MARKER");
+ string end = (string)AppDomain.CurrentDomain.GetData ("END_CODE_MARKER");
+ response.Write (begin + "<strong>Application error handled</strong>" + end);
+ }
+ Server.ClearError ();
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0"?>
+<!--
+Web.config file for TestWebApp.
+
+The settings that can be used in this file are documented at
+http://www.mono-project.com/Config_system.web and
+http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
+-->
+<configuration>
+ <system.web>
+ <compilation defaultLanguage="C#" debug="true">
+ <assemblies>
+ </assemblies>
+ </compilation>
+ <customErrors mode="RemoteOnly">
+ </customErrors>
+ <authentication mode="None">
+ </authentication>
+ <authorization>
+ <allow users="*" />
+ </authorization>
+ <httpHandlers>
+ </httpHandlers>
+ <trace enabled="false" localOnly="true" pageOutput="false" requestLimit="10" traceMode="SortByTime" />
+ <sessionState mode="InProc" cookieless="false" timeout="20" />
+ <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
+ <pages>
+ </pages>
+ </system.web>
+</configuration>
\ No newline at end of file
--- /dev/null
+<%@ Page Language="C#" %>
+<script runat="server">
+ void Page_Load (object sender, EventArgs e)
+ {
+ throw new InvalidOperationException ("test");
+ }
+</script>
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html>
+<head runat="server">
+ <title>Default</title>
+</head>
+<body>
+ <form id="form1" runat="server">
+ </form>
+</body>
+</html>
\ No newline at end of file
--- /dev/null
+<%@ Application CodeFile="global.asax.cs" Inherits="TestWebApp.Global" %>
--- /dev/null
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Web;
+using System.Web.SessionState;
+
+namespace TestWebApp
+{
+ public partial class Global : System.Web.HttpApplication
+ {
+ protected virtual void Application_Error (Object sender, EventArgs e)
+ {
+ Response.Redirect ("http://google.com/");
+ }
+ }
+}
--- /dev/null
+<?xml version="1.0"?>
+<!--
+Web.config file for TestWebApp.
+
+The settings that can be used in this file are documented at
+http://www.mono-project.com/Config_system.web and
+http://msdn2.microsoft.com/en-us/library/b5ysx397.aspx
+-->
+<configuration>
+ <system.web>
+ <compilation defaultLanguage="C#" debug="true">
+ <assemblies>
+ </assemblies>
+ </compilation>
+ <customErrors mode="RemoteOnly">
+ </customErrors>
+ <authentication mode="None">
+ </authentication>
+ <authorization>
+ <allow users="*" />
+ </authorization>
+ <httpHandlers>
+ </httpHandlers>
+ <trace enabled="false" localOnly="true" pageOutput="false" requestLimit="10" traceMode="SortByTime" />
+ <sessionState mode="InProc" cookieless="false" timeout="20" />
+ <globalization requestEncoding="utf-8" responseEncoding="utf-8" />
+ <pages>
+ </pages>
+ </system.web>
+</configuration>
\ No newline at end of file