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 ConfigurationPropertyCollection properties;
68 static HttpRuntimeSection ()
70 apartmentThreadingProp = new ConfigurationProperty ("apartmentThreading", typeof (bool), false);
71 appRequestQueueLimitProp = new ConfigurationProperty ("appRequestQueueLimit", typeof (int), 5000,
72 TypeDescriptor.GetConverter (typeof (int)),
73 new IntegerValidator (1, Int32.MaxValue),
74 ConfigurationPropertyOptions.None);
75 delayNotificationTimeoutProp = new ConfigurationProperty ("delayNotificationTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (5),
76 PropertyHelper.TimeSpanSecondsConverter,
77 PropertyHelper.DefaultValidator,
78 ConfigurationPropertyOptions.None);
79 enableProp = new ConfigurationProperty ("enable", typeof (bool), true);
80 enableHeaderCheckingProp = new ConfigurationProperty ("enableHeaderChecking", typeof (bool), true);
81 enableKernelOutputCacheProp = new ConfigurationProperty ("enableKernelOutputCache", typeof (bool), true);
82 enableVersionHeaderProp = new ConfigurationProperty ("enableVersionHeader", typeof (bool), true);
83 executionTimeoutProp = new ConfigurationProperty ("executionTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (110),
84 PropertyHelper.TimeSpanSecondsConverter,
85 PropertyHelper.PositiveTimeSpanValidator,
86 ConfigurationPropertyOptions.None);
87 maxRequestLengthProp = new ConfigurationProperty ("maxRequestLength", typeof (int), 4096,
88 TypeDescriptor.GetConverter (typeof (int)),
89 PropertyHelper.IntFromZeroToMaxValidator,
90 ConfigurationPropertyOptions.None);
91 maxWaitChangeNotificationProp = new ConfigurationProperty ("maxWaitChangeNotification", typeof (int), 0,
92 TypeDescriptor.GetConverter (typeof (int)),
93 PropertyHelper.IntFromZeroToMaxValidator,
94 ConfigurationPropertyOptions.None);
95 minFreeThreadsProp = new ConfigurationProperty ("minFreeThreads", typeof (int), 8,
96 TypeDescriptor.GetConverter (typeof (int)),
97 PropertyHelper.IntFromZeroToMaxValidator,
98 ConfigurationPropertyOptions.None);
99 minLocalRequestFreeThreadsProp = new ConfigurationProperty ("minLocalRequestFreeThreads", typeof (int), 4,
100 TypeDescriptor.GetConverter (typeof (int)),
101 PropertyHelper.IntFromZeroToMaxValidator,
102 ConfigurationPropertyOptions.None);
103 requestLengthDiskThresholdProp = new ConfigurationProperty ("requestLengthDiskThreshold", typeof (int), 80,
104 TypeDescriptor.GetConverter (typeof (int)),
105 new IntegerValidator (1, Int32.MaxValue),
106 ConfigurationPropertyOptions.None);
107 requireRootedSaveAsPathProp = new ConfigurationProperty ("requireRootedSaveAsPath", typeof (bool), true);
108 sendCacheControlHeaderProp = new ConfigurationProperty ("sendCacheControlHeader", typeof (bool), true);
109 shutdownTimeoutProp = new ConfigurationProperty ("shutdownTimeout", typeof (TimeSpan), TimeSpan.FromSeconds (90),
110 PropertyHelper.TimeSpanSecondsConverter,
111 PropertyHelper.DefaultValidator,
112 ConfigurationPropertyOptions.None);
113 useFullyQualifiedRedirectUrlProp = new ConfigurationProperty ("useFullyQualifiedRedirectUrl", typeof (bool), false);
114 waitChangeNotificationProp = new ConfigurationProperty ("waitChangeNotification", typeof (int), 0,
115 TypeDescriptor.GetConverter (typeof (int)),
116 PropertyHelper.IntFromZeroToMaxValidator,
117 ConfigurationPropertyOptions.None);
118 requestPathInvalidCharactersProp = new ConfigurationProperty ("requestPathInvalidCharacters", typeof (string), "<,>,*,%,&,:,\\,?");
119 requestValidationTypeProp = new ConfigurationProperty ("requestValidationType", typeof (string),"System.Web.Util.RequestValidator",
120 TypeDescriptor.GetConverter (typeof (string)),
121 PropertyHelper.NonEmptyStringValidator,
122 ConfigurationPropertyOptions.None);
123 requestValidationModeProp = new ConfigurationProperty ("requestValidationMode", typeof (Version), new Version (4, 0),
124 PropertyHelper.VersionConverter,
125 PropertyHelper.DefaultValidator,
126 ConfigurationPropertyOptions.None);
127 maxQueryStringLengthProp = new ConfigurationProperty ("maxQueryStringLength", typeof (int), 2048,
128 TypeDescriptor.GetConverter (typeof (int)),
129 PropertyHelper.IntFromZeroToMaxValidator,
130 ConfigurationPropertyOptions.None);
131 maxUrlLengthProp = new ConfigurationProperty ("maxUrlLength", typeof (int), 260,
132 TypeDescriptor.GetConverter (typeof (int)),
133 PropertyHelper.IntFromZeroToMaxValidator,
134 ConfigurationPropertyOptions.None);
135 encoderTypeProp = new ConfigurationProperty ("encoderType", typeof (string), "System.Web.Util.HttpEncoder",
136 TypeDescriptor.GetConverter (typeof (string)),
137 PropertyHelper.NonEmptyStringValidator,
138 ConfigurationPropertyOptions.None);
139 relaxedUrlToFileSystemMappingProp = new ConfigurationProperty ("relaxedUrlToFileSystemMapping", typeof (bool), false);
140 targetFrameworkProp = new ConfigurationProperty ("targetFramework", typeof (Version), new Version (4, 0),
141 PropertyHelper.VersionConverter,
142 PropertyHelper.DefaultValidator,
143 ConfigurationPropertyOptions.None);
145 properties = new ConfigurationPropertyCollection();
146 properties.Add (apartmentThreadingProp);
147 properties.Add (appRequestQueueLimitProp);
148 properties.Add (delayNotificationTimeoutProp);
149 properties.Add (enableProp);
150 properties.Add (enableHeaderCheckingProp);
151 properties.Add (enableKernelOutputCacheProp);
152 properties.Add (enableVersionHeaderProp);
153 properties.Add (executionTimeoutProp);
154 properties.Add (maxRequestLengthProp);
155 properties.Add (maxWaitChangeNotificationProp);
156 properties.Add (minFreeThreadsProp);
157 properties.Add (minLocalRequestFreeThreadsProp);
158 properties.Add (requestLengthDiskThresholdProp);
159 properties.Add (requireRootedSaveAsPathProp);
160 properties.Add (sendCacheControlHeaderProp);
161 properties.Add (shutdownTimeoutProp);
162 properties.Add (useFullyQualifiedRedirectUrlProp);
163 properties.Add (waitChangeNotificationProp);
164 properties.Add (requestPathInvalidCharactersProp);
165 properties.Add (requestValidationTypeProp);
166 properties.Add (requestValidationModeProp);
167 properties.Add (maxQueryStringLengthProp);
168 properties.Add (maxUrlLengthProp);
169 properties.Add (encoderTypeProp);
170 properties.Add (relaxedUrlToFileSystemMappingProp);
171 properties.Add (targetFrameworkProp);
174 public HttpRuntimeSection()
178 [ConfigurationProperty ("apartmentThreading", DefaultValue = "False")]
179 public bool ApartmentThreading {
180 get { return (bool) base[apartmentThreadingProp]; }
181 set { base[apartmentThreadingProp] = value; }
184 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
185 [ConfigurationProperty ("appRequestQueueLimit", DefaultValue = "5000")]
186 public int AppRequestQueueLimit {
187 get { return (int) base[appRequestQueueLimitProp]; }
188 set { base[appRequestQueueLimitProp] = value; }
191 [TypeConverter (typeof (TimeSpanSecondsConverter))]
192 [ConfigurationProperty ("delayNotificationTimeout", DefaultValue = "00:00:05")]
193 public TimeSpan DelayNotificationTimeout {
194 get { return (TimeSpan) base[delayNotificationTimeoutProp]; }
195 set { base[delayNotificationTimeoutProp] = value; }
198 [ConfigurationProperty ("enable", DefaultValue = "True")]
200 get { return (bool) base[enableProp]; }
201 set { base[enableProp] = value; }
204 [ConfigurationProperty ("enableHeaderChecking", DefaultValue = "True")]
205 public bool EnableHeaderChecking {
206 get { return (bool) base[enableHeaderCheckingProp]; }
207 set { base[enableHeaderCheckingProp] = value; }
210 [ConfigurationProperty ("enableKernelOutputCache", DefaultValue = "True")]
211 public bool EnableKernelOutputCache {
212 get { return (bool) base[enableKernelOutputCacheProp]; }
213 set { base[enableKernelOutputCacheProp] = value; }
216 [ConfigurationProperty ("enableVersionHeader", DefaultValue = "True")]
217 public bool EnableVersionHeader {
218 get { return (bool) base[enableVersionHeaderProp]; }
219 set { base[enableVersionHeaderProp] = value; }
222 [TypeConverter (typeof (TimeSpanSecondsConverter))]
223 [TimeSpanValidator (MinValueString = "00:00:00")]
224 [ConfigurationProperty ("executionTimeout", DefaultValue = "00:01:50")]
225 public TimeSpan ExecutionTimeout {
226 get { return (TimeSpan) base[executionTimeoutProp]; }
227 set { base[executionTimeoutProp] = value; }
230 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
231 [ConfigurationProperty ("maxRequestLength", DefaultValue = "4096")]
232 public int MaxRequestLength {
233 get { return (int) base[maxRequestLengthProp]; }
234 set { base[maxRequestLengthProp] = value; }
237 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
238 [ConfigurationProperty ("maxWaitChangeNotification", DefaultValue = "0")]
239 public int MaxWaitChangeNotification {
240 get { return (int) base[maxWaitChangeNotificationProp]; }
241 set { base[maxWaitChangeNotificationProp] = value; }
244 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
245 [ConfigurationProperty ("minFreeThreads", DefaultValue = "8")]
246 public int MinFreeThreads {
247 get { return (int) base[minFreeThreadsProp]; }
248 set { base[minFreeThreadsProp] = value; }
251 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
252 [ConfigurationProperty ("minLocalRequestFreeThreads", DefaultValue = "4")]
253 public int MinLocalRequestFreeThreads {
254 get { return (int) base[minLocalRequestFreeThreadsProp]; }
255 set { base[minLocalRequestFreeThreadsProp] = value; }
258 [IntegerValidator (MinValue = 1, MaxValue = Int32.MaxValue)]
259 [ConfigurationProperty ("requestLengthDiskThreshold", DefaultValue = "80")]
260 public int RequestLengthDiskThreshold {
261 get { return (int) base[requestLengthDiskThresholdProp]; }
262 set { base[requestLengthDiskThresholdProp] = value; }
265 [ConfigurationProperty ("requireRootedSaveAsPath", DefaultValue = "True")]
266 public bool RequireRootedSaveAsPath {
267 get { return (bool) base[requireRootedSaveAsPathProp]; }
268 set { base[requireRootedSaveAsPathProp] = value; }
271 [ConfigurationProperty ("sendCacheControlHeader", DefaultValue = "True")]
272 public bool SendCacheControlHeader {
273 get { return (bool) base[sendCacheControlHeaderProp]; }
274 set { base[sendCacheControlHeaderProp] = value; }
277 [TypeConverter (typeof (TimeSpanSecondsConverter))]
278 [ConfigurationProperty ("shutdownTimeout", DefaultValue = "00:01:30")]
279 public TimeSpan ShutdownTimeout {
280 get { return (TimeSpan) base[shutdownTimeoutProp]; }
281 set { base[shutdownTimeoutProp] = value; }
284 [ConfigurationProperty ("useFullyQualifiedRedirectUrl", DefaultValue = "False")]
285 public bool UseFullyQualifiedRedirectUrl {
286 get { return (bool) base[useFullyQualifiedRedirectUrlProp]; }
287 set { base[useFullyQualifiedRedirectUrlProp] = value; }
290 [IntegerValidator (MinValue = 0, MaxValue = Int32.MaxValue)]
291 [ConfigurationProperty ("waitChangeNotification", DefaultValue = "0")]
292 public int WaitChangeNotification {
293 get { return (int) base[waitChangeNotificationProp]; }
294 set { base[waitChangeNotificationProp] = value; }
297 [ConfigurationProperty ("requestPathInvalidCharacters", DefaultValue = ",*,%,&,:,\\,?")]
298 public string RequestPathInvalidCharacters {
299 get { return (string) base [requestPathInvalidCharactersProp]; }
300 set { base [requestPathInvalidCharactersProp] = value; }
303 [ConfigurationProperty ("requestValidationType", DefaultValue = "System.Web.Util.RequestValidator")]
304 [StringValidator (MinLength = 1)]
305 public string RequestValidationType {
306 get { return (string) base [requestValidationTypeProp]; }
307 set { base [requestValidationTypeProp] = value; }
310 [ConfigurationProperty ("requestValidationMode", DefaultValue = "4.0")]
311 [TypeConverter ("System.Web.Configuration.VersionConverter")]
312 public Version RequestValidationMode {
313 get { return (Version) base [requestValidationModeProp]; }
314 set { base [requestValidationModeProp] = value; }
317 [IntegerValidator (MinValue = 0)]
318 [ConfigurationProperty ("maxQueryStringLength", DefaultValue = "2048")]
319 public int MaxQueryStringLength {
320 get { return (int) base [maxQueryStringLengthProp]; }
321 set { base [maxQueryStringLengthProp] = value; }
324 [IntegerValidator (MinValue = 0)]
325 [ConfigurationProperty ("maxUrlLength", DefaultValue = "260")]
326 public int MaxUrlLength {
327 get { return (int) base [maxUrlLengthProp]; }
328 set { base [maxUrlLengthProp] = value; }
331 [StringValidator (MinLength = 1)]
332 [ConfigurationProperty ("encoderType", DefaultValue = "System.Web.Util.HttpEncoder")]
333 public string EncoderType {
334 get { return (string) base [encoderTypeProp]; }
335 set { base [encoderTypeProp] = value; }
338 [ConfigurationProperty ("relaxedUrlToFileSystemMapping", DefaultValue = "False")]
339 public bool RelaxedUrlToFileSystemMapping {
340 get { return (bool) base [relaxedUrlToFileSystemMappingProp]; }
341 set { base [relaxedUrlToFileSystemMappingProp] = value; }
343 [ConfigurationProperty ("targetFramework", DefaultValue = "4.0")]
344 [TypeConverter ("System.Web.Configuration.VersionConverter")]
345 public Version TargetFramework {
346 get { return (Version) base [targetFrameworkProp]; }
347 set { base [targetFrameworkProp] = value; }
349 protected internal override ConfigurationPropertyCollection Properties {
350 get { return properties; }