Skip to content

Commit 0add367

Browse files
author
DevTrends
committed
improved SecurityException message in medium trust environments
1 parent db9dd44 commit 0add367

File tree

5 files changed

+19
-7
lines changed

5 files changed

+19
-7
lines changed

DevTrends.MvcDonutCaching/CacheSettingsManager.cs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public CacheSettingsManager()
1919
}
2020
catch (SecurityException)
2121
{
22-
Debug.WriteLine("MvcDonutCaching does not have permission to read web.config section. Using default provider.");
22+
Trace.WriteLine("MvcDonutCaching does not have permission to read web.config section 'OutputCacheSection'. Using default provider.");
2323
_outputCacheSection = new OutputCacheSection { DefaultProviderName = AspnetInternalProviderName, EnableOutputCache = true };
2424
}
2525

@@ -37,7 +37,16 @@ public string RetrieveOutputCacheProviderType()
3737

3838
public OutputCacheProfile RetrieveOutputCacheProfile(string cacheProfileName)
3939
{
40-
var outputCacheSettingsSection = (OutputCacheSettingsSection)ConfigurationManager.GetSection("system.web/caching/outputCacheSettings");
40+
OutputCacheSettingsSection outputCacheSettingsSection;
41+
42+
try
43+
{
44+
outputCacheSettingsSection = (OutputCacheSettingsSection)ConfigurationManager.GetSection("system.web/caching/outputCacheSettings");
45+
}
46+
catch (SecurityException)
47+
{
48+
throw new SecurityException("MvcDonutCaching does not have permission to read web.config section 'OutputCacheSettingsSection'.");
49+
}
4150

4251
if (outputCacheSettingsSection != null && outputCacheSettingsSection.OutputCacheProfiles.Count > 0)
4352
{

DevTrends.MvcDonutCaching/DonutOutputCacheAttribute.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,10 @@ public override void OnResultExecuted(ResultExecutedContext filterContext)
103103

104104
public void OnException(ExceptionContext filterContext)
105105
{
106-
ExecuteCallback(filterContext, true);
106+
if (_cacheSettings != null)
107+
{
108+
ExecuteCallback(filterContext, true);
109+
}
107110
}
108111

109112
private void ExecuteCallback(ControllerContext context, bool hasErrors)

DevTrends.MvcDonutCaching/Properties/AssemblyInfo.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
[assembly: AssemblyConfiguration("")]
77
[assembly: AssemblyCompany("DevTrends")]
88
[assembly: AssemblyProduct("DevTrends.MvcDonutCaching")]
9-
[assembly: AssemblyCopyright("Copyright © DevTrends 2011")]
9+
[assembly: AssemblyCopyright("Copyright © DevTrends 2012")]
1010
[assembly: AssemblyTrademark("")]
1111
[assembly: AssemblyCulture("")]
1212
[assembly: ComVisible(false)]
1313
[assembly: Guid("ebcc3291-f04a-4511-b7eb-ddf57a74ada9")]
14-
[assembly: AssemblyVersion("1.1.1")]
15-
[assembly: AssemblyFileVersion("1.1.1")]
14+
[assembly: AssemblyVersion("1.1.2")]
15+
[assembly: AssemblyFileVersion("1.1.2")]

nuget/MvcDonutCaching.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>MvcDonutCaching</id>
5-
<version>1.1.1</version>
5+
<version>1.1.2</version>
66
<authors>Paul Hiles</authors>
77
<owners>DevTrends</owners>
88
<licenseUrl>http://mvcdonutcaching.codeplex.com/license</licenseUrl>
512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)