From 739c3a6bd51740443bddf3028cc04a016f137ff4 Mon Sep 17 00:00:00 2001 From: Sebastien Ros Date: Wed, 19 Sep 2012 18:21:51 -0700 Subject: [PATCH] #19030: Fixing Azure unit test Work Item: 19030 --HG-- branch : 1.x --- AzurePackage.proj | 3 ++- src/Orchard.Azure/AzureFileSystem.cs | 27 ++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/AzurePackage.proj b/AzurePackage.proj index 980530f4a..d888b4e04 100644 --- a/AzurePackage.proj +++ b/AzurePackage.proj @@ -16,7 +16,8 @@ - + + diff --git a/src/Orchard.Azure/AzureFileSystem.cs b/src/Orchard.Azure/AzureFileSystem.cs index 5e49d8f83..a01503af3 100644 --- a/src/Orchard.Azure/AzureFileSystem.cs +++ b/src/Orchard.Azure/AzureFileSystem.cs @@ -299,22 +299,27 @@ namespace Orchard.Azure { } try { - string applicationHost = System.Environment.ExpandEnvironmentVariables(@"%windir%\system32\inetsrv\config\applicationHost.config"); - string webConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/").FilePath; + try { + string applicationHost = System.Environment.ExpandEnvironmentVariables(@"%windir%\system32\inetsrv\config\applicationHost.config"); + string webConfig = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(null).FilePath; - // search for custom mime types in web.config and applicationhost.config - foreach (var configFile in new[] {webConfig, applicationHost}) { - if (File.Exists(configFile)) { - var xdoc = XDocument.Load(configFile); - var mimeMap = xdoc.XPathSelectElements("//staticContent/mimeMap[@fileExtension='" + extension + "']").FirstOrDefault(); - if (mimeMap != null) { - var mimeType = mimeMap.Attribute("mimeType"); - if (mimeType != null) { - return mimeType.Value; + // search for custom mime types in web.config and applicationhost.config + foreach (var configFile in new[] {webConfig, applicationHost}) { + if (File.Exists(configFile)) { + var xdoc = XDocument.Load(configFile); + var mimeMap = xdoc.XPathSelectElements("//staticContent/mimeMap[@fileExtension='" + extension + "']").FirstOrDefault(); + if (mimeMap != null) { + var mimeType = mimeMap.Attribute("mimeType"); + if (mimeType != null) { + return mimeType.Value; + } } } } } + catch { + // ignore issues with web.config to fall back to registry + } // search into the registry RegistryKey regKey = Registry.ClassesRoot.OpenSubKey(extension.ToLower());