2 // System.Web.Configuration.HttpRuntimeSection
5 // Chris Toshok (toshok@ximian.com)
7 // (C) 2005 Novell, Inc (http://www.novell.com)
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33 using System.ComponentModel;
34 using System.Configuration;
36 namespace System.Web.Configuration
38 public sealed class HttpRuntimeSection : ConfigurationSection
40 static ConfigurationProperty apartmentThreadingProp;
41 static ConfigurationProperty appRequestQueueLimitProp;
42 static ConfigurationProperty delayNotificationTimeoutProp;
43 static ConfigurationProperty enableProp;
44 static ConfigurationProperty enableHeaderCheckingProp;
45 static ConfigurationProperty enableKernelOutputCacheProp;
46 static ConfigurationProperty enableVersionHeaderProp;
47 static ConfigurationProperty executionTimeoutProp;
48 static ConfigurationProperty maxRequestLengthProp;
49 static ConfigurationProperty maxWaitChangeNotificationProp;
50 static ConfigurationProperty minFreeThreadsProp;
51 static ConfigurationProperty minLocalRequestFreeThreadsProp;
52 static ConfigurationProperty requestLengthDiskThresholdProp;
53 static ConfigurationProperty requireRootedSaveAsPathProp;
54 static ConfigurationProperty sendCacheControlHeaderProp;
55 static ConfigurationProperty shutdownTimeoutProp;
56 static ConfigurationProperty useFullyQualifiedRedirectUrlProp;
57 static ConfigurationProperty waitChangeNotificationProp;
58 static ConfigurationProperty requestPathInvalidCharactersProp;
59 static ConfigurationProperty requestValidationTypeProp;
60 static ConfigurationProperty requestValidationModeProp;
61 static ConfigurationProperty maxQueryStringLengthProp;
62 static ConfigurationProperty maxUrlLengthProp;
63 static ConfigurationProperty encoderTypeProp;
64 static ConfigurationProperty relaxedUrlToFileSystemMappingProp;
65 static ConfigurationProperty targetFrameworkProp;
66 static ConfigurationProperty allowDynamicModuleRegistrationProp;
67 static ConfigurationPropertyCollection properties;
69 static HttpRuntimeSection ()
71 apartmentThreadingProp = new ConfigurationProperty ("apartmentThreading", typeof (bool), false);
72 appRequestQueueLimitProp = new ConfigurationProperty ("appRequestQueueLimit", typeof (int), 5000,
73 TypeDescriptor.GetConverter (typeof (int)),
74 new IntegerValidator (1, Int32.MaxValue),
75 ConfigurationPropertyOptions.None);
76 delayNotificationTimeoutProp = new ConfigurationProperty ("delayNotificationTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5),
77 PropertyHelper.TimeSpanSecondsConverter,
78 PropertyHelper.DefaultValidator,
79 ConfigurationPropertyOptions.None);
80 enableProp = new ConfigurationProperty ("enable", typeof (bool), true);
81 enableHeaderCheckingProp = new ConfigurationProperty ("enableHeaderChecking", typeof (bool), true);
82 enableKernelOutputCacheProp = new ConfigurationProperty ("enableKernelOutputCache", typeof (bool), true);
83 enableVersionHeaderProp = new ConfigurationProperty ("enableVersionHeader", typeof (bool), true);
84 executionTimeoutProp = new ConfigurationProperty ("executionTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (110),
85 PropertyHelper.TimeSpanSecondsConverter,
86 PropertyHelper.PositiveTimeSpanValidator,
87 ConfigurationPropertyOptions.None);
88 maxRequestLengthProp = new ConfigurationProperty ("maxRequestLength", typeof (int), 4096,
89 TypeDescriptor.GetConverter (typeof (int)),
90 PropertyHelper.IntFromZeroToMaxValidator,
91 ConfigurationPropertyOptions.None);
92 maxWaitChangeNotificationProp = new ConfigurationProperty ("maxWaitChangeNotification", typeof (int), 0,
93 TypeDescriptor.GetConverter (typeof (int)),
94 PropertyHelper.IntFromZeroToMaxValidator,
95 ConfigurationPropertyOptions.None);
96 minFreeThreadsProp = new ConfigurationProperty ("minFreeThreads", typeof (int), 8,
97 TypeDescriptor.GetConverter (typeof (int)),
98 PropertyHelper.IntFromZeroToMaxValidator,
99 ConfigurationPropertyOptions.None);
100 minLocalRequestFreeThreadsProp = new ConfigurationProperty ("minLocalRequestFreeThreads", typeof (int), 4,
101 TypeDescriptor.GetConverter (typeof (int)),
102 PropertyHelper.IntFromZeroToMaxValidator,
103 ConfigurationPropertyOptions.None);
104 requestLengthDiskThresholdProp = new ConfigurationProperty ("requestLengthDiskThreshold", typeof (int), 80,
105 TypeDescriptor.GetConverter (typeof (int)),
106 new IntegerValidator (1, Int32.MaxValue),
107 ConfigurationPropertyOptions.None);
108 requireRootedSaveAsPathProp = new ConfigurationProperty ("requireRootedSaveAsPath", typeof (bool), true);
109 sendCacheControlHeaderProp = new ConfigurationProperty ("sendCacheControlHeader", typeof (bool), true);
110 shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (90),
111 PropertyHelper.TimeSpanSecondsConverter,
112 PropertyHelper.DefaultValidator,
113 ConfigurationPropertyOptions.None);
114 useFullyQualifiedRedirectUrlProp = new ConfigurationProperty ("useFullyQualifiedRedirectUrl", typeof (bool), false);
115 waitChangeNotificationProp = new ConfigurationProperty ("waitChangeNotification", typeof (int), 0,
116 TypeDescriptor.GetConverter (typeof (int)),
117 PropertyHelper.IntFromZeroToMaxValidator,
118 ConfigurationPropertyOptions.None);
119 requestPathInvalidCharactersProp = new ConfigurationProperty ("requestPathInvalidCharacters", typeof (string), "<,>,*,%,&,:,\\,?");
120 requestValidationTypeProp = new ConfigurationProperty ("requestValidationType", typeof (string),"System.Web.Util.RequestValidator",
121 TypeDescriptor.GetConverter (typeof (string)),
122 PropertyHelper.NonEmptyStringValidator,
123 ConfigurationPropertyOptions.None);
124 requestValidationModeProp = new ConfigurationProperty ("requestValidationMode", typeof (Version), new Version (4, 0),
125 PropertyHelper.VersionConverter,
126 PropertyHelper.DefaultValidator,
127 ConfigurationPropertyOptions.None);
128 maxQueryStringLengthProp = new ConfigurationProperty ("maxQueryStringLength", typeof (int), 2048,
129 TypeDescriptor.GetConverter (typeof (int)),
130 PropertyHelper.IntFromZeroToMaxValidator,
131 ConfigurationPropertyOptions.None);
132 maxUrlLengthProp = new ConfigurationProperty ("maxUrlLength", typeof (int), 260,
133 TypeDescriptor.GetConverter (typeof (int)),
134 PropertyHelper.IntFromZeroToMaxValidator,
135 ConfigurationPropertyOptions.None);
136 encoderTypeProp = new ConfigurationProperty ("encoderType", typeof (string), "System.Web.Util.HttpEncoder",
137 TypeDescriptor.GetConverter (typeof (string)),
138 PropertyHelper.NonEmptyStringValidator,
139 ConfigurationPropertyOptions.None);
140 relaxedUrlToFileSystemMappingProp = new ConfigurationProperty ("relaxedUrlToFileSystemMapping", typeof (bool), false);
141 targetFrameworkProp = new ConfigurationProperty ("targetFramework", typeof (Version), new Version (4, 0),
142 PropertyHelper.VersionConverter,
143 PropertyHelper.DefaultValidator,
144 ConfigurationPropertyOptions.None);
145 allowDynamicModuleRegistrationProp = new ConfigurationProperty ("allowDynamicModuleRegistration", typeof(bool), true,
146 ConfigurationPropertyOptions.None);
148 properties = new ConfigurationPropertyCollection();
149 properties.Add (apartmentThreadingProp);
150 properties.Add (appRequestQueueLimitProp);
151 properties.Add (delayNotificationTimeoutProp);
152 properties.Add (enableProp);
153 properties.Add (enableHeaderCheckingProp);
154 properties.Add (enableKernelOutputCacheProp);
155 properties.Add (enableVersionHeaderProp);
156 properties.Add (executionTimeoutProp);
157 properties.Add (maxRequestLengthProp);
158 properties.Add (maxWaitChangeNotificationProp);
159 properties.Add (minFreeThreadsProp);
160 properties.Add (minLocalRequestFreeThreadsProp);
161 properties.Add (requestLengthDiskThresholdProp);
162 properties.Add (requireRootedSaveAsPathProp);
163 properties.Add (sendCacheControlHeaderProp);
164 properties.Add (shutdownTimeoutProp);
165 properties.Add (useFullyQualifiedRedirectUrlProp);
166 properties.Add (waitChangeNotificationProp);
167 properties.Add (requestPathInvalidCharactersProp);
168 properties.Add (requestValidationTypeProp);
169 properties.Add (requestValidationModeProp);
170 properties.Add (maxQueryStringLengthProp);
171 properties.Add (maxUrlLengthProp);
172 properties.Add (encoderTypeProp);
173 properties.Add (relaxedUrlToFileSystemMappingProp);
174 properties.Add (targetFrameworkProp);
175 properties.Add (allowDynamicModuleRegistrationProp);
178 public HttpRuntimeSection()
182 [ConfigurationProperty ("apartmentThreading", DefaultValue = "False")]
183 public bool ApartmentThreading {
184 get { return (bool) base[apartmentThreadingProp]; }
185 set { base[apartmentThreadingProp] = value; }
188 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
189 [ConfigurationProperty ("appRequestQueueLimit", DefaultValue = "5000")]
190 public int AppRequestQueueLimit {
191 get { return (int) base[appRequestQueueLimitProp]; }
192 set { base[appRequestQueueLimitProp] = value; }
195 [TypeConverter (typeof (TimeSpanSecondsConverter))]
196 [ConfigurationProperty ("delayNotificationTimeout", DefaultValue = "00:00:05")]
197 public TimeSpan DelayNotificationTimeout {
198 get { return (TimeSpan) base[delayNotificationTimeoutProp]; }
199 set { base[delayNotificationTimeoutProp] = value; }
202 [ConfigurationProperty ("enable", DefaultValue = "True")]
204 get { return (bool) base[enableProp]; }
205 set { base[enableProp] = value; }
208 [ConfigurationProperty ("enableHeaderChecking", DefaultValue = "True")]
209 public bool EnableHeaderChecking {
210 get { return (bool) base[enableHeaderCheckingProp]; }
211 set { base[enableHeaderCheckingProp] = value; }
214 [ConfigurationProperty ("enableKernelOutputCache", DefaultValue = "True")]
215 public bool EnableKernelOutputCache {
216 get { return (bool) base[enableKernelOutputCacheProp]; }
217 set { base[enableKernelOutputCacheProp] = value; }
220 [ConfigurationProperty ("enableVersionHeader", DefaultValue = "True")]
221 public bool EnableVersionHeader {
222 get { return (bool) base[enableVersionHeaderProp]; }
223 set { base[enableVersionHeaderProp] = value; }
226 [TypeConverter (typeof (TimeSpanSecondsConverter))]
227 [TimeSpanValidator (MinValueString = "00:00:00")]
228 [ConfigurationProperty ("executionTimeout", DefaultValue = "00:01:50")]
229 public TimeSpan ExecutionTimeout {
230 get { return (TimeSpan) base[executionTimeoutProp]; }
231 set { base[executionTimeoutProp] = value; }
234 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
235 [ConfigurationProperty ("maxRequestLength", DefaultValue = "4096")]
236 public int MaxRequestLength {
237 get { return (int) base[maxRequestLengthProp]; }
238 set { base[maxRequestLengthProp] = value; }
241 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
242 [ConfigurationProperty ("maxWaitChangeNotification", DefaultValue = "0")]
243 public int MaxWaitChangeNotification {
244 get { return (int) base[maxWaitChangeNotificationProp]; }
245 set { base[maxWaitChangeNotificationProp] = value; }
248 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
249 [ConfigurationProperty ("minFreeThreads", DefaultValue = "8")]
250 public int MinFreeThreads {
251 get { return (int) base[minFreeThreadsProp]; }
252 set { base[minFreeThreadsProp] = value; }
255 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
256 [ConfigurationProperty ("minLocalRequestFreeThreads", DefaultValue = "4")]
257 public int MinLocalRequestFreeThreads {
258 get { return (int) base[minLocalRequestFreeThreadsProp]; }
259 set { base[minLocalRequestFreeThreadsProp] = value; }
262 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
263 [ConfigurationProperty ("requestLengthDiskThreshold", DefaultValue = "80")]
264 public int RequestLengthDiskThreshold {
265 get { return (int) base[requestLengthDiskThresholdProp]; }
266 set { base[requestLengthDiskThresholdProp] = value; }
269 [ConfigurationProperty ("requireRootedSaveAsPath", DefaultValue = "True")]
270 public bool RequireRootedSaveAsPath {
271 get { return (bool) base[requireRootedSaveAsPathProp]; }
272 set { base[requireRootedSaveAsPathProp] = value; }
275 [ConfigurationProperty ("sendCacheControlHeader", DefaultValue = "True")]
276 public bool SendCacheControlHeader {
277 get { return (bool) base[sendCacheControlHeaderProp]; }
278 set { base[sendCacheControlHeaderProp] = value; }
281 [TypeConverter (typeof (TimeSpanSecondsConverter))]
282 [ConfigurationProperty ("shutdownTimeout", DefaultValue = "00:01:30")]
283 public TimeSpan ShutdownTimeout {
284 get { return (TimeSpan) base[shutdownTimeoutProp]; }
285 set { base[shutdownTimeoutProp] = value; }
288 [ConfigurationProperty ("useFullyQualifiedRedirectUrl", DefaultValue = "False")]
289 public bool UseFullyQualifiedRedirectUrl {
290 get { return (bool) base[useFullyQualifiedRedirectUrlProp]; }
291 set { base[useFullyQualifiedRedirectUrlProp] = value; }
294 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
295 [ConfigurationProperty ("waitChangeNotification", DefaultValue = "0")]
296 public int WaitChangeNotification {
297 get { return (int) base[waitChangeNotificationProp]; }
298 set { base[waitChangeNotificationProp] = value; }
301 [ConfigurationProperty ("requestPathInvalidCharacters", DefaultValue = ",*,%,&,:,\\,?")]
302 public string RequestPathInvalidCharacters {
303 get { return (string) base [requestPathInvalidCharactersProp]; }
304 set { base [requestPathInvalidCharactersProp] = value; }
307 [ConfigurationProperty ("requestValidationType", DefaultValue = "System.Web.Util.RequestValidator")]
308 [StringValidator (MinLength = 1)]
309 public string RequestValidationType {
310 get { return (string) base [requestValidationTypeProp]; }
311 set { base [requestValidationTypeProp] = value; }
314 [ConfigurationProperty ("requestValidationMode", DefaultValue = "4.0")]
315 [TypeConverter ("System.Web.Configuration.VersionConverter")]
316 public Version RequestValidationMode {
317 get { return (Version) base [requestValidationModeProp]; }
318 set { base [requestValidationModeProp] = value; }
321 [IntegerValidator (MinValue = 0)]
322 [ConfigurationProperty ("maxQueryStringLength", DefaultValue = "2048")]
323 public int MaxQueryStringLength {
324 get { return (int) base [maxQueryStringLengthProp]; }
325 set { base [maxQueryStringLengthProp] = value; }
328 [IntegerValidator (MinValue = 0)]
329 [ConfigurationProperty ("maxUrlLength", DefaultValue = "260")]
330 public int MaxUrlLength {
331 get { return (int) base [maxUrlLengthProp]; }
332 set { base [maxUrlLengthProp] = value; }
335 [StringValidator (MinLength = 1)]
336 [ConfigurationProperty ("encoderType", DefaultValue = "System.Web.Util.HttpEncoder")]
337 public string EncoderType {
338 get { return (string) base [encoderTypeProp]; }
339 set { base [encoderTypeProp] = value; }
342 [ConfigurationProperty ("relaxedUrlToFileSystemMapping", DefaultValue = "False")]
343 public bool RelaxedUrlToFileSystemMapping {
344 get { return (bool) base [relaxedUrlToFileSystemMappingProp]; }
345 set { base [relaxedUrlToFileSystemMappingProp] = value; }
347 [ConfigurationProperty ("targetFramework", DefaultValue = "4.0")]
348 [TypeConverter ("System.Web.Configuration.VersionConverter")]
349 public Version TargetFramework {
350 get { return (Version) base [targetFrameworkProp]; }
351 set { base [targetFrameworkProp] = value; }
353 protected internal override ConfigurationPropertyCollection Properties {
354 get { return properties; }
356 [ConfigurationProperty ("allowDynamicModuleRegistration", DefaultValue = "True")]
357 public bool AllowDynamicModuleRegistration {
358 get { return (bool) base [allowDynamicModuleRegistrationProp]; }
359 set { base [allowDynamicModuleRegistrationProp] = value; }