Handles writing a Web.Config to disk that uses Url Authorization to prevent visitors from accessing the files directly. Alternative Web.config content can be specified, this is a general-purpose implementation. Uses UTF-8 encoding. Also provides methods for efficient verification that the file still exists. Thread-safe.
More...
|
| WebConfigWriter (ILoggerProvider lp, string physicalDirPath) |
|
| WebConfigWriter (ILoggerProvider lp, string physicalDirPath, string alternateWebConfigContents) |
|
void | CheckWebConfigEvery5 () |
| Verifies a Web.config file is present in the directory every 5 minutes that the function is called, including the first time. More...
|
|
void | CheckWebConfigOnce () |
| If CheckWebConfig has never executed, it is executed immediately, but only once. Verifies a Web.config file is present in the directory, and creates it if needed. More...
|
|
void | CheckWebConfig () |
| Verifies a Web.config file is present in the directory, and creates it if needed. More...
|
|
|
virtual string | getNewWebConfigContents () |
|
void | _checkWebConfig () |
| Should only be called inside a lock. Creates the cache dir and the web.config file if they are missing. Updates _lastCheckedWebConfig and _checkedWebConfigOnce More...
|
|
|
ILoggerProvider | lp = null |
|
string | physicalDirPath = null |
|
string | webConfigContents |
| This string contains the contents of a web.conig file that sets URL authorization to "deny all" inside the current directory. More...
|
|
Handles writing a Web.Config to disk that uses Url Authorization to prevent visitors from accessing the files directly. Alternative Web.config content can be specified, this is a general-purpose implementation. Uses UTF-8 encoding. Also provides methods for efficient verification that the file still exists. Thread-safe.
Definition at line 14 of file WebConfigWriter.cs.
void ImageResizer.Plugins.DiskCache.WebConfigWriter._checkWebConfig |
( |
| ) |
|
|
inlineprotected |
Should only be called inside a lock. Creates the cache dir and the web.config file if they are missing. Updates _lastCheckedWebConfig and _checkedWebConfigOnce
- Parameters
-
Definition at line 85 of file WebConfigWriter.cs.
87 string webConfigPath = physicalDirPath.TrimEnd(
'/',
'\\') + System.IO.Path.DirectorySeparatorChar +
"Web.config";
88 if (lp.Logger != null) lp.Logger.Debug(
"Verifying Web.config exists in cache directory.");
89 if (System.IO.File.Exists(webConfigPath))
return;
93 if (!System.IO.Directory.Exists(physicalDirPath))
94 System.IO.Directory.CreateDirectory(physicalDirPath);
96 if (lp.Logger != null) lp.Logger.Info(
"Creating missing Web.config in cache directory.");
98 System.IO.File.WriteAllText(webConfigPath, getNewWebConfigContents(),UTF8Encoding.UTF8);
101 _lastCheckedWebConfig = DateTime.UtcNow;
102 _checkedWebConfigOnce =
true;
void ImageResizer.Plugins.DiskCache.WebConfigWriter.CheckWebConfig |
( |
| ) |
|
|
inline |
Verifies a Web.config file is present in the directory, and creates it if needed.
Definition at line 75 of file WebConfigWriter.cs.
76 lock (_webConfigSyncObj) {
void _checkWebConfig()
Should only be called inside a lock. Creates the cache dir and the web.config file if they are missin...
void ImageResizer.Plugins.DiskCache.WebConfigWriter.CheckWebConfigEvery5 |
( |
| ) |
|
|
inline |
Verifies a Web.config file is present in the directory every 5 minutes that the function is called, including the first time.
- Returns
Definition at line 50 of file WebConfigWriter.cs.
51 if (_lastCheckedWebConfig < DateTime.UtcNow.Subtract(
new TimeSpan(0, 5, 0))) {
52 lock (_webConfigSyncObj) {
53 if (_lastCheckedWebConfig < DateTime.UtcNow.Subtract(
new TimeSpan(0, 5, 0)))
void _checkWebConfig()
Should only be called inside a lock. Creates the cache dir and the web.config file if they are missin...
void ImageResizer.Plugins.DiskCache.WebConfigWriter.CheckWebConfigOnce |
( |
| ) |
|
|
inline |
If CheckWebConfig has never executed, it is executed immediately, but only once. Verifies a Web.config file is present in the directory, and creates it if needed.
- Parameters
-
Definition at line 65 of file WebConfigWriter.cs.
66 if (_checkedWebConfigOnce)
return;
67 lock (_webConfigSyncObj) {
68 if (_checkedWebConfigOnce)
return;
void _checkWebConfig()
Should only be called inside a lock. Creates the cache dir and the web.config file if they are missin...
string ImageResizer.Plugins.DiskCache.WebConfigWriter.webConfigContents |
|
protected |
Initial value:=
"<?xml version=\"1.0\"?>" +
"<configuration xmlns=\"http://schemas.microsoft.com/.NetConfiguration/v2.0\">" +
"<system.web><authorization>" +
"<deny users=\"*\" />" +
"</authorization></system.web></configuration>"
This string contains the contents of a web.conig file that sets URL authorization to "deny all" inside the current directory.
Definition at line 30 of file WebConfigWriter.cs.
The documentation for this class was generated from the following file: