From d8a68737abd08750a32a056c75366e57bf4d11fc Mon Sep 17 00:00:00 2001 From: Dario Solera Date: Thu, 1 Jul 2010 10:45:36 +0000 Subject: [PATCH] Fixed issue occurring when calling formatting-related code from asynchronous threads (HttpContext is unavailable). --- AssemblyVersion.cs | 4 ++-- Core/UrlTools.cs | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/AssemblyVersion.cs b/AssemblyVersion.cs index be2b2df..1a731a3 100644 --- a/AssemblyVersion.cs +++ b/AssemblyVersion.cs @@ -16,5 +16,5 @@ using System.Reflection; // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: -[assembly: AssemblyVersion("3.0.3.555")] -[assembly: AssemblyFileVersion("3.0.3.555")] +[assembly: AssemblyVersion("3.0.3.556")] +[assembly: AssemblyFileVersion("3.0.3.556")] diff --git a/Core/UrlTools.cs b/Core/UrlTools.cs index 97e5341..e370076 100644 --- a/Core/UrlTools.cs +++ b/Core/UrlTools.cs @@ -132,9 +132,15 @@ namespace ScrewTurn.Wiki { if(tempString.StartsWith("++")) return tempString.Substring(2); - string nspace = HttpContext.Current.Request["NS"]; - if(string.IsNullOrEmpty(nspace)) nspace = null; - if(nspace == null) nspace = GetCurrentNamespace(); + string nspace = null; + if(HttpContext.Current != null) { + // HttpContext.Current can be null when executing asynchronous tasks + // The point is that BuildUrl is called without namespace info only from the web application, so HttpContext is available in that case + // When the context is not available, in all cases BuildUrl is called by the formatter, that has already included namespace info in the URL + nspace = HttpContext.Current.Request["NS"]; + if(string.IsNullOrEmpty(nspace)) nspace = null; + if(nspace == null) nspace = GetCurrentNamespace(); + } if(string.IsNullOrEmpty(nspace)) nspace = null; else nspace = Pages.FindNamespace(nspace).Name;