}\r
}\r
\r
- void PreSendRequestHeaders (object sender, EventArgs e) {\r
+ void PreSendRequestHeaders (object sender, EventArgs e)\r
+ {\r
HttpApplication app = (HttpApplication) sender;\r
HttpContext context = app.Context;\r
if (context.Request.Headers ["X-MicrosoftAjax"] == "Delta=true") {\r
if (p == null && context.CurrentHandler is IServiceProvider)\r
p = (Page) ((IServiceProvider) context.CurrentHandler).GetService (typeof (Page));\r
#endif\r
- if (p == null)\r
- return;\r
- ScriptManager sm = ScriptManager.GetCurrent (p);\r
- if (sm == null)\r
- return;\r
+ ScriptManager sm = ScriptManager.GetCurrentInternal (p);\r
if (context.Response.StatusCode == 302) {\r
context.Response.StatusCode = 200;\r
context.Response.ClearContent ();\r
- if (context.Error == null || sm.AllowCustomErrorsRedirect)\r
+ if (context.Error == null || (sm != null && sm.AllowCustomErrorsRedirect))\r
ScriptManager.WriteCallbackRedirect (context.Response.Output, context.Response.RedirectLocation);\r
else\r
- sm.WriteCallbackException (context.Response.Output, context.Error, false);\r
- }\r
- else if (context.Error != null) {\r
+ ScriptManager.WriteCallbackException (sm, context.Response.Output, context.Error, false);\r
+ } else if (context.Error != null) {\r
context.Response.StatusCode = 200;\r
context.Response.ClearContent ();\r
- sm.WriteCallbackException (context.Response.Output, context.Error, true);\r
+ ScriptManager.WriteCallbackException (sm, context.Response.Output, context.Error, true);\r
}\r
}\r
}\r
using System.Web.Script.Services;
using System.Xml;
using System.Collections.ObjectModel;
+using System.Web.Util;
namespace System.Web.UI
{
if (IsDeploymentRetail)
return false;
- CompilationSection compilation = (CompilationSection) WebConfigurationManager.GetSection ("system.web/compilation");
- if (!compilation.Debug && (ScriptMode == ScriptMode.Auto || ScriptMode == ScriptMode.Inherit))
+ if (!RuntimeHelpers.DebuggingEnabled && (ScriptMode == ScriptMode.Auto || ScriptMode == ScriptMode.Inherit))
return false;
if (ScriptMode == ScriptMode.Release)
return GetCurrentInternal (page);
}
- static ScriptManager GetCurrentInternal (Page page)
+ internal static ScriptManager GetCurrentInternal (Page page)
{
if (page == null)
return null;
#endregion
- internal void WriteCallbackException (TextWriter output, Exception ex, bool writeMessage) {
+ internal static void WriteCallbackException (ScriptManager current, TextWriter output, Exception ex, bool writeMessage)
+ {
#if TARGET_DOTNET
if (ex is HttpUnhandledException)
ex = ex.InnerException;
#endif
HttpException httpEx = ex as HttpException;
- string message = AsyncPostBackErrorMessage;
+ string message = current != null ? current.AsyncPostBackErrorMessage : null;
if (String.IsNullOrEmpty (message) && writeMessage) {
- HttpContext ctx = HttpContext.Current;
-
- if (IsDebuggingEnabled)
+ if ((current != null && current.IsDebuggingEnabled) || (current == null && RuntimeHelpers.DebuggingEnabled))
message = ex.ToString ();
else
message = ex.Message;
values.Add (ExceptionPageTemplate.Template_DetailsName, sb.ToString ());
}
- if (showTrace)
- values.Add (ExceptionPageTemplate.Template_StackTraceName, HtmlEncode (baseEx.StackTrace.ToString ()));
+ if (showTrace) {
+ string stackTrace = baseEx.StackTrace;
+ if (!String.IsNullOrEmpty (stackTrace))
+ values.Add (ExceptionPageTemplate.Template_StackTraceName, HtmlEncode (stackTrace));
+ }
}
static string HtmlEncode (string s)