From: Marek Habersack Date: Tue, 20 Apr 2010 22:35:31 +0000 (-0000) Subject: 2010-04-21 Marek Habersack X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=9b87d46bdf11e08d30fe313737bd3822dbc21cbd;p=mono.git 2010-04-21 Marek Habersack * 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 Also added two more tests for the issue. svn path=/trunk/mcs/; revision=155841 --- diff --git a/mcs/class/System.Web/System.Web/ChangeLog b/mcs/class/System.Web/System.Web/ChangeLog index d5de0aaabc5..8cc0c03e41e 100644 --- a/mcs/class/System.Web/System.Web/ChangeLog +++ b/mcs/class/System.Web/System.Web/ChangeLog @@ -1,3 +1,9 @@ +2010-04-21 Marek Habersack + + * 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 * HttpException.cs: handle situations when current exception is an diff --git a/mcs/class/System.Web/System.Web/HttpApplication.cs b/mcs/class/System.Web/System.Web/HttpApplication.cs index c87d4b4f329..4b55fdaeb55 100644 --- a/mcs/class/System.Web/System.Web/HttpApplication.cs +++ b/mcs/class/System.Web/System.Web/HttpApplication.cs @@ -870,7 +870,8 @@ namespace System.Web 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) @@ -931,7 +932,6 @@ namespace System.Web } catch (ThreadAbortException taex) { object obj = taex.ExceptionState; Thread.ResetAbort (); - stop_processing = true; if (obj is StepTimeout) ProcessError (new HttpException ("The request timed out.")); else { @@ -939,11 +939,12 @@ namespace System.Web 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 (); } } diff --git a/mcs/class/System.Web/Test/standalone-tests/Unhandled_Exception_Global_Asax.cs b/mcs/class/System.Web/Test/standalone-tests/Unhandled_Exception_Global_Asax.cs index 6945e9bebc2..bcb569cc281 100644 --- a/mcs/class/System.Web/Test/standalone-tests/Unhandled_Exception_Global_Asax.cs +++ b/mcs/class/System.Web/Test/standalone-tests/Unhandled_Exception_Global_Asax.cs @@ -40,7 +40,7 @@ using NUnit.Framework; 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 { @@ -65,9 +65,11 @@ namespace StandAloneTests.Unhandled_Exception_Global_Asax void Default_Aspx (string result, TestRunItem runItem) { - string originalHtml = @"Application error handled"; + 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"); } } @@ -101,5 +103,67 @@ namespace StandAloneTests.Unhandled_Exception_Global_Asax 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 runItems) + { + runItems.Add (new TestRunItem ("/default.aspx", Default_Aspx)); + + return true; + } + + void Default_Aspx (string result, TestRunItem runItem) + { + string originalHtml = @"Application error handled"; + + 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 runItems) + { + runItems.Add (new TestRunItem ("/default.aspx", Default_Aspx)); + + return true; + } + + void Default_Aspx (string result, TestRunItem runItem) + { + string originalHtml = @"

Object moved to here

"; + + Assert.IsTrue (result.IndexOf (originalHtml) != -1, "#A1"); + } + } } diff --git a/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/default.aspx b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/default.aspx new file mode 100644 index 00000000000..5f7522ee6fb --- /dev/null +++ b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/default.aspx @@ -0,0 +1,17 @@ +<%@ Page Language="C#" %> + + + + + Default + + +
+
+ + \ No newline at end of file diff --git a/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/global.asax b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/global.asax new file mode 100644 index 00000000000..4bc28a6526a --- /dev/null +++ b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/global.asax @@ -0,0 +1 @@ +<%@ Application CodeFile="global.asax.cs" Inherits="TestWebApp.Global" %> diff --git a/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/global.asax.cs b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/global.asax.cs new file mode 100644 index 00000000000..01a6f3c5c1b --- /dev/null +++ b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/global.asax.cs @@ -0,0 +1,23 @@ +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 + "Application error handled" + end); + } + Server.ClearError (); + } + } +} diff --git a/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/web.config b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/web.config new file mode 100644 index 00000000000..27ba12c8d23 --- /dev/null +++ b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_03/web.config @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/default.aspx b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/default.aspx new file mode 100644 index 00000000000..5f7522ee6fb --- /dev/null +++ b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/default.aspx @@ -0,0 +1,17 @@ +<%@ Page Language="C#" %> + + + + + Default + + +
+
+ + \ No newline at end of file diff --git a/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/global.asax b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/global.asax new file mode 100644 index 00000000000..4bc28a6526a --- /dev/null +++ b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/global.asax @@ -0,0 +1 @@ +<%@ Application CodeFile="global.asax.cs" Inherits="TestWebApp.Global" %> diff --git a/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/global.asax.cs b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/global.asax.cs new file mode 100644 index 00000000000..ff8b54d4967 --- /dev/null +++ b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/global.asax.cs @@ -0,0 +1,16 @@ +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/"); + } + } +} diff --git a/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/web.config b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/web.config new file mode 100644 index 00000000000..27ba12c8d23 --- /dev/null +++ b/mcs/class/System.Web/Test/standalone/Unhandled_Exception_Global_Asax/test_04/web.config @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file