1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884
|
//------------------------------------------------------------------------------
// <copyright file="HttpRuntimeSection.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//------------------------------------------------------------------------------
namespace System.Web.Configuration {
using System;
using System.ComponentModel;
using System.Configuration;
using System.Runtime.Versioning;
using System.Text;
using System.Web.Security.AntiXss;
using System.Web.Util;
public sealed class HttpRuntimeSection : ConfigurationSection {
#if !FEATURE_PAL // FEATURE_PAL-specific timeout values
internal const int DefaultExecutionTimeout = 110;
#else // !FEATURE_PAL
// The timeout needs to be extended, since Coriolis/Rotor is much slower
// especially platforms like Solaris wan't be able to process complicated
// requests if in debug mode.
// Remove or change this once the real timeout is known
#if DEBUG
internal const int DefaultExecutionTimeout = 110 * 10;
#else // DEBUG
internal const int DefaultExecutionTimeout = 110 * 5;
#endif // DEBUG
#endif // !FEATURE_PAL
internal const int DefaultMaxRequestLength = 4096 * 1024; // 4MB
internal const int DefaultRequestLengthDiskThreshold = 80 * 1024; // 80KB
internal const int DefaultMinFreeThreads = 8;
internal const int DefaultMinLocalRequestFreeThreads = 4;
internal const int DefaultAppRequestQueueLimit = 100;
internal const int DefaultShutdownTimeout = 90;
internal const int DefaultDelayNotificationTimeout = 0;
internal const int DefaultWaitChangeNotification = 0;
internal const int DefaultMaxWaitChangeNotification = 0;
internal const bool DefaultAllowDynamicModuleRegistration = true;
internal const bool DefaultEnableKernelOutputCache = true;
internal const bool DefaultRequireRootedSaveAsPath = true;
internal const bool DefaultSendCacheControlHeader = true;
internal const string DefaultEncoderType = "System.Web.Util.HttpEncoder";
internal static readonly Version DefaultRequestValidationMode = VersionUtil.FrameworkDefault;
internal const string DefaultRequestValidationModeString = VersionUtil.FrameworkDefaultString;
internal const string DefaultRequestValidationType = "System.Web.Util.RequestValidator";
internal const string DefaultRequestPathInvalidCharacters = "<,>,*,%,&,:,\\,?";
internal const int DefaultMaxUrlLength = 260;
internal const int DefaultMaxQueryStringLength = 2048;
internal const bool DefaultRelaxedUrlToFileSystemMapping = false;
internal const string DefaultTargetFramework = null;
private AsyncPreloadModeFlags asyncPreloadModeCache;
private bool asyncPreloadModeCached = false;
private bool enableVersionHeaderCache = true;
private bool enableVersionHeaderCached = false;
private TimeSpan executionTimeoutCache;
private bool executionTimeoutCached = false;
private bool sendCacheControlHeaderCached = false;
private bool sendCacheControlHeaderCache;
private FcnMode fcnModeCache;
private bool fcnModeCached = false;
private static ConfigurationPropertyCollection _properties;
private static readonly ConfigurationProperty _propAsyncPreloadMode =
new ConfigurationProperty("asyncPreloadMode",
typeof(AsyncPreloadModeFlags),
AsyncPreloadModeFlags.None,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propExecutionTimeout =
new ConfigurationProperty("executionTimeout",
typeof(TimeSpan),
TimeSpan.FromSeconds((double)DefaultExecutionTimeout),
StdValidatorsAndConverters.TimeSpanSecondsConverter,
StdValidatorsAndConverters.PositiveTimeSpanValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propMaxRequestLength =
new ConfigurationProperty("maxRequestLength",
typeof(int),
4096,
null,
StdValidatorsAndConverters.NonZeroPositiveIntegerValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propRequestLengthDiskThreshold =
new ConfigurationProperty("requestLengthDiskThreshold",
typeof(int),
80,
null,
StdValidatorsAndConverters.NonZeroPositiveIntegerValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propUseFullyQualifiedRedirectUrl =
new ConfigurationProperty("useFullyQualifiedRedirectUrl",
typeof(bool),
false,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propMinFreeThreads =
new ConfigurationProperty("minFreeThreads",
typeof(int),
8,
null,
StdValidatorsAndConverters.PositiveIntegerValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propMinLocalRequestFreeThreads =
new ConfigurationProperty("minLocalRequestFreeThreads",
typeof(int),
4,
null,
StdValidatorsAndConverters.PositiveIntegerValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propAppRequestQueueLimit =
new ConfigurationProperty("appRequestQueueLimit",
typeof(int),
5000,
null,
StdValidatorsAndConverters.NonZeroPositiveIntegerValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propEnableKernelOutputCache =
new ConfigurationProperty("enableKernelOutputCache",
typeof(bool),
true,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propEnableVersionHeader =
new ConfigurationProperty("enableVersionHeader",
typeof(bool),
true,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propRequireRootedSaveAsPath =
new ConfigurationProperty("requireRootedSaveAsPath",
typeof(bool),
true,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propEnable =
new ConfigurationProperty("enable",
typeof(bool),
true,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propDefaultRegexMatchTimeout =
new ConfigurationProperty("defaultRegexMatchTimeout",
typeof(TimeSpan),
TimeSpan.Zero,
null,
StdValidatorsAndConverters.RegexMatchTimeoutValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propShutdownTimeout =
new ConfigurationProperty("shutdownTimeout",
typeof(TimeSpan),
TimeSpan.FromSeconds((double)DefaultShutdownTimeout),
StdValidatorsAndConverters.TimeSpanSecondsConverter,
null,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propDelayNotificationTimeout =
new ConfigurationProperty("delayNotificationTimeout",
typeof(TimeSpan),
TimeSpan.FromSeconds((double)DefaultDelayNotificationTimeout),
StdValidatorsAndConverters.TimeSpanSecondsConverter,
null,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propWaitChangeNotification =
new ConfigurationProperty("waitChangeNotification",
typeof(int),
0,
null,
StdValidatorsAndConverters.PositiveIntegerValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propMaxWaitChangeNotification =
new ConfigurationProperty("maxWaitChangeNotification",
typeof(int),
0,
null,
StdValidatorsAndConverters.PositiveIntegerValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propEnableHeaderChecking =
new ConfigurationProperty("enableHeaderChecking",
typeof(bool),
true,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propSendCacheControlHeader =
new ConfigurationProperty("sendCacheControlHeader",
typeof(bool),
DefaultSendCacheControlHeader,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propApartmentThreading =
new ConfigurationProperty("apartmentThreading",
typeof(bool),
false,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propEncoderType =
new ConfigurationProperty("encoderType",
typeof(string),
DefaultEncoderType,
null,
StdValidatorsAndConverters.NonEmptyStringValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propRequestValidationMode =
new ConfigurationProperty("requestValidationMode",
typeof(Version),
DefaultRequestValidationMode,
StdValidatorsAndConverters.VersionConverter,
null,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propRequestValidationType =
new ConfigurationProperty("requestValidationType",
typeof(string),
DefaultRequestValidationType,
null,
StdValidatorsAndConverters.NonEmptyStringValidator,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propRequestPathInvalidCharacters =
new ConfigurationProperty("requestPathInvalidCharacters",
typeof(string),
DefaultRequestPathInvalidCharacters,
StdValidatorsAndConverters.WhiteSpaceTrimStringConverter,
null,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propMaxUrlLength =
new ConfigurationProperty("maxUrlLength",
typeof(int),
DefaultMaxUrlLength,
null,
new IntegerValidator(0, 2097151), // Max from VS 330766
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propMaxQueryStringLength =
new ConfigurationProperty("maxQueryStringLength",
typeof(int),
DefaultMaxQueryStringLength,
null,
new IntegerValidator(0, 2097151), // Max from VS 330766
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propRelaxedUrlToFileSystemMapping =
new ConfigurationProperty("relaxedUrlToFileSystemMapping",
typeof(bool),
DefaultRelaxedUrlToFileSystemMapping,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propAllowDynamicModuleRegistration =
new ConfigurationProperty("allowDynamicModuleRegistration",
typeof(bool),
DefaultAllowDynamicModuleRegistration,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propFcnMode =
new ConfigurationProperty("fcnMode",
typeof(FcnMode),
FcnMode.NotSet,
ConfigurationPropertyOptions.None);
private static readonly ConfigurationProperty _propTargetFramework =
new ConfigurationProperty("targetFramework",
typeof(string),
DefaultTargetFramework,
ConfigurationPropertyOptions.None);
private int _MaxRequestLengthBytes;
private int _RequestLengthDiskThresholdBytes;
private static String s_versionHeader = null;
private Version _requestValidationMode;
/* <!--
httpRuntime Attributes:
asyncPreloadMode="None" [None | Form | FormMultiPart | AllFormTypes | NonForm | All]
executionTimeout="[seconds]" - time in seconds before request is automatically timed out
maxRequestLength="[KBytes]" - KBytes size of maximum request length to accept
requestLengthDiskThreshold="[KBytes]" - KBytes threshold to use disk for posted content temporary storage
useFullyQualifiedRedirectUrl="[true|false]" - Fully qualifiy the URL for client redirects
minFreeThreads="[count]" - minimum number of free thread to allow execution of new requests
minLocalRequestFreeThreads="[count]" - minimum number of free thread to allow execution of new local requests
appRequestQueueLimit="[count]" - maximum number of requests queued for the application; the sum of requests in all application queues is bounded from above by the global requestQueueLimit in the processModel section
enableKernelOutputCache="[true|false]" - enable the http.sys cache on IIS6 and higher - default is true
enableVersionHeader="[true|false]" - outputs X-AspNet-Version header with each request
requireRootedSaveAsPath="[true|false]" - the filename argument to SaveAs methods must be a rooted path
enable="[true|false]" - enable processing requests for this application
waitChangeNotification="[seconds]" - time in seconds to wait for another file change notification before restarting the AppDomain
maxWaitChangeNotification="[seconds]" - maximum time in seconds to wait from the first file change notification before restarting the AppDomain
enableHeaderChecking="[true|false]" - when true, CRLF pairs in response headers are encoded
encoderType="[typename]" - type used for custom HTTP encoding (HTML encoding, URL encoding, etc.)
requestValidationMode="[version]" - "2.0" to turn request validation on only for pages, "4.0" for the entire pipeline, "4.5" to enable granular request validation
requestValidationType="[typename]" - type used for custom request validation
RequestPathInvalidCharacters="[string]" - comma seperated list of chars in the URL to reject
maxUrlLength="[int]" - Max length of Request.Path
maxQueryStringLength="[int]" - Max length of QueryString
relaxedUrlToFileSystemMapping = "false"
allowDynamicModuleRegistration="[true|flase]" - used to block RegisterModule method calls
targetFramework="[string]" - framework version behavior to trigger CLR "quirks mode" settings
-->
<httpRuntime
asyncPreloadMode="None"
executionTimeout="110"
maxRequestLength="4096"
requestLengthDiskThreshold="80"
useFullyQualifiedRedirectUrl="false"
minFreeThreads="8"
minLocalRequestFreeThreads="4"
appRequestQueueLimit="5000"
enableVersionHeader="true"
requireRootedSaveAsPath="true"
enable="true"
encoderType="System.Web.Util.HttpEncoder"
requestValidationMode="4.0"
requestValidationType="System.Web.Util.RequestValidator"
RequestPathInvalidCharacters="<,>,*,%,&,:,\,?"
maxUrlLength="260"
maxQueryStringLength="4096"
relaxedUrlToFileSystemMapping = "false"
allowDynamicModuleRegistration = "true"
/>
*/
static HttpRuntimeSection() {
// Property initialization
_properties = new ConfigurationPropertyCollection();
_properties.Add(_propAsyncPreloadMode);
_properties.Add(_propExecutionTimeout);
_properties.Add(_propMaxRequestLength);
_properties.Add(_propRequestLengthDiskThreshold);
_properties.Add(_propUseFullyQualifiedRedirectUrl);
_properties.Add(_propMinFreeThreads);
_properties.Add(_propMinLocalRequestFreeThreads);
_properties.Add(_propAppRequestQueueLimit);
_properties.Add(_propEnableKernelOutputCache);
_properties.Add(_propEnableVersionHeader);
_properties.Add(_propRequireRootedSaveAsPath);
_properties.Add(_propEnable);
_properties.Add(_propDefaultRegexMatchTimeout);
_properties.Add(_propShutdownTimeout);
_properties.Add(_propDelayNotificationTimeout);
_properties.Add(_propWaitChangeNotification);
_properties.Add(_propMaxWaitChangeNotification);
_properties.Add(_propEnableHeaderChecking);
_properties.Add(_propSendCacheControlHeader);
_properties.Add(_propApartmentThreading);
_properties.Add(_propEncoderType);
_properties.Add(_propRequestValidationMode);
_properties.Add(_propRequestValidationType);
_properties.Add(_propRequestPathInvalidCharacters);
_properties.Add(_propMaxUrlLength);
_properties.Add(_propMaxQueryStringLength);
_properties.Add(_propRelaxedUrlToFileSystemMapping);
_properties.Add(_propAllowDynamicModuleRegistration);
_properties.Add(_propFcnMode);
_properties.Add(_propTargetFramework);
}
public HttpRuntimeSection() {
_MaxRequestLengthBytes = -1;
_RequestLengthDiskThresholdBytes = -1;
}
protected override ConfigurationPropertyCollection Properties {
get {
return _properties;
}
}
[ConfigurationProperty("asyncPreloadMode", DefaultValue = AsyncPreloadModeFlags.None)]
public AsyncPreloadModeFlags AsyncPreloadMode {
get {
if (asyncPreloadModeCached == false) {
asyncPreloadModeCache = (AsyncPreloadModeFlags)base[_propAsyncPreloadMode];
asyncPreloadModeCached = true;
}
return asyncPreloadModeCache;
}
set {
base[_propAsyncPreloadMode] = value;
asyncPreloadModeCache = value;
}
}
[ConfigurationProperty("fcnMode", DefaultValue = FcnMode.NotSet)]
public FcnMode FcnMode {
get {
if (!fcnModeCached) {
fcnModeCache = (FcnMode)base[_propFcnMode];
fcnModeCached = true;
}
return fcnModeCache;
}
set {
base[_propFcnMode] = value;
fcnModeCache = value;
}
}
[ConfigurationProperty("executionTimeout", DefaultValue = "00:01:50")]
[TypeConverter(typeof(TimeSpanSecondsConverter))]
[TimeSpanValidator(MinValueString = "00:00:00", MaxValueString = TimeSpanValidatorAttribute.TimeSpanMaxValue)]
public TimeSpan ExecutionTimeout {
get {
if (executionTimeoutCached == false) {
executionTimeoutCache = (TimeSpan)base[_propExecutionTimeout];
executionTimeoutCached = true;
}
return executionTimeoutCache;
}
set {
base[_propExecutionTimeout] = value;
executionTimeoutCache = value;
}
}
[ConfigurationProperty("maxRequestLength", DefaultValue = 4096)]
[IntegerValidator(MinValue = 0)]
public int MaxRequestLength {
get {
return (int)base[_propMaxRequestLength];
}
set {
if (value < RequestLengthDiskThreshold) {
throw new ConfigurationErrorsException(SR.GetString(SR.Config_max_request_length_smaller_than_max_request_length_disk_threshold),
ElementInformation.Properties[_propMaxRequestLength.Name].Source,
ElementInformation.Properties[_propMaxRequestLength.Name].LineNumber);
}
base[_propMaxRequestLength] = value;
} //
}
[ConfigurationProperty("requestLengthDiskThreshold", DefaultValue = 80)]
[IntegerValidator(MinValue = 1)]
public int RequestLengthDiskThreshold {
get {
return (int)base[_propRequestLengthDiskThreshold];
}
set {
if (value > MaxRequestLength) {
throw new ConfigurationErrorsException(SR.GetString(SR.Config_max_request_length_disk_threshold_exceeds_max_request_length),
ElementInformation.Properties[_propRequestLengthDiskThreshold.Name].Source,
ElementInformation.Properties[_propRequestLengthDiskThreshold.Name].LineNumber);
}
base[_propRequestLengthDiskThreshold] = value;
}
}
[ConfigurationProperty("useFullyQualifiedRedirectUrl", DefaultValue = false)]
public bool UseFullyQualifiedRedirectUrl {
get {
return (bool)base[_propUseFullyQualifiedRedirectUrl];
}
set {
base[_propUseFullyQualifiedRedirectUrl] = value;
}
}
[ConfigurationProperty("minFreeThreads", DefaultValue = 8)]
[IntegerValidator(MinValue = 0)]
public int MinFreeThreads {
get {
return (int)base[_propMinFreeThreads];
}
set {
base[_propMinFreeThreads] = value;
}
}
[ConfigurationProperty("minLocalRequestFreeThreads", DefaultValue = 4)]
[IntegerValidator(MinValue = 0)]
public int MinLocalRequestFreeThreads {
get {
return (int)base[_propMinLocalRequestFreeThreads];
}
set {
base[_propMinLocalRequestFreeThreads] = value;
}
}
[ConfigurationProperty("appRequestQueueLimit", DefaultValue = 5000)]
[IntegerValidator(MinValue = 1)]
public int AppRequestQueueLimit {
get {
return (int)base[_propAppRequestQueueLimit];
}
set {
base[_propAppRequestQueueLimit] = value;
}
}
[ConfigurationProperty("enableKernelOutputCache", DefaultValue = true)]
public bool EnableKernelOutputCache {
get {
return (bool)base[_propEnableKernelOutputCache];
}
set {
base[_propEnableKernelOutputCache] = value;
}
}
[ConfigurationProperty("enableVersionHeader", DefaultValue = true)]
public bool EnableVersionHeader {
get {
if (enableVersionHeaderCached == false) {
enableVersionHeaderCache = (bool)base[_propEnableVersionHeader];
enableVersionHeaderCached = true;
}
return enableVersionHeaderCache;
}
set {
base[_propEnableVersionHeader] = value;
enableVersionHeaderCache = value;
}
}
[ConfigurationProperty("apartmentThreading", DefaultValue = false)]
public bool ApartmentThreading {
get {
return (bool)base[_propApartmentThreading];
}
set {
base[_propApartmentThreading] = value;
}
}
[ConfigurationProperty("requireRootedSaveAsPath", DefaultValue = true)]
public bool RequireRootedSaveAsPath {
get {
return (bool)base[_propRequireRootedSaveAsPath];
}
set {
base[_propRequireRootedSaveAsPath] = value;
}
}
[ConfigurationProperty("enable", DefaultValue = true)]
public bool Enable {
get {
return (bool)base[_propEnable];
}
set {
base[_propEnable] = value;
}
}
[ConfigurationProperty("targetFramework", DefaultValue = DefaultTargetFramework)]
public string TargetFramework {
get {
return (string)base[_propTargetFramework];
}
set {
base[_propTargetFramework] = value;
}
}
// method is used to provide a FrameworkName to be used for the AppDomainSetup.TargetFrameworkName property
internal FrameworkName GetTargetFrameworkName() {
string targetFramework = TargetFramework; // only read from property once so the value can't change in the middle of processing
if (String.IsNullOrEmpty(targetFramework)) {
// no target framework; let caller perform default behavior
return null;
}
else {
Version version;
if (!Version.TryParse(targetFramework, out version)) {
// if this doesn't parse as a valid Version object, throw an exception containing the erroneous line in config
PropertyInformation targetFrameworkPropInfo = ElementInformation.Properties["targetFramework"];
throw new ConfigurationErrorsException(SR.GetString(SR.HttpRuntimeSection_TargetFramework_Invalid),
filename: targetFrameworkPropInfo.Source,
line: targetFrameworkPropInfo.LineNumber);
}
// check succeeded
return new FrameworkName(".NETFramework", version);
}
}
[ConfigurationProperty("sendCacheControlHeader", DefaultValue = DefaultSendCacheControlHeader)]
public bool SendCacheControlHeader {
get {
if (sendCacheControlHeaderCached == false) {
sendCacheControlHeaderCache = (bool)base[_propSendCacheControlHeader];
sendCacheControlHeaderCached = true;
}
return sendCacheControlHeaderCache;
}
set {
base[_propSendCacheControlHeader] = value;
sendCacheControlHeaderCache = value;
}
}
[ConfigurationProperty("defaultRegexMatchTimeout", DefaultValue = "00:00:00")]
[RegexMatchTimeoutValidator]
public TimeSpan DefaultRegexMatchTimeout {
get {
return (TimeSpan)base[_propDefaultRegexMatchTimeout];
}
set {
base[_propDefaultRegexMatchTimeout] = value;
}
}
[ConfigurationProperty("shutdownTimeout", DefaultValue = "00:01:30")]
[TypeConverter(typeof(TimeSpanSecondsConverter))]
public TimeSpan ShutdownTimeout {
get {
return (TimeSpan)base[_propShutdownTimeout];
}
set {
base[_propShutdownTimeout] = value;
}
}
[ConfigurationProperty("delayNotificationTimeout", DefaultValue = "00:00:00")]
[TypeConverter(typeof(TimeSpanSecondsConverter))]
public TimeSpan DelayNotificationTimeout {
get {
return (TimeSpan)base[_propDelayNotificationTimeout];
}
set {
base[_propDelayNotificationTimeout] = value;
}
}
[ConfigurationProperty("waitChangeNotification", DefaultValue = 0)]
[IntegerValidator(MinValue = 0)]
public int WaitChangeNotification {
get {
return (int)base[_propWaitChangeNotification];
}
set {
base[_propWaitChangeNotification] = value;
}
}
[ConfigurationProperty("maxWaitChangeNotification", DefaultValue = 0)]
[IntegerValidator(MinValue = 0)]
public int MaxWaitChangeNotification {
get {
return (int)base[_propMaxWaitChangeNotification];
}
set {
base[_propMaxWaitChangeNotification] = value;
}
}
[ConfigurationProperty("enableHeaderChecking", DefaultValue = true)]
public bool EnableHeaderChecking {
get {
return (bool)base[_propEnableHeaderChecking];
}
set {
base[_propEnableHeaderChecking] = value;
}
}
[ConfigurationProperty("encoderType", DefaultValue = DefaultEncoderType)]
[StringValidator(MinLength = 1)]
public string EncoderType {
get {
return (string)base[_propEncoderType];
}
set {
base[_propEncoderType] = value;
}
}
[ConfigurationProperty("requestValidationMode", DefaultValue = DefaultRequestValidationModeString)]
[TypeConverter(typeof(VersionConverter))]
public Version RequestValidationMode {
get {
if (_requestValidationMode == null) {
_requestValidationMode = (Version)base[_propRequestValidationMode];
}
return _requestValidationMode;
}
set {
_requestValidationMode = value;
base[_propRequestValidationMode] = value;
}
}
[ConfigurationProperty("requestValidationType", DefaultValue = DefaultRequestValidationType)]
[StringValidator(MinLength = 1)]
public string RequestValidationType {
get {
return (string)base[_propRequestValidationType];
}
set {
base[_propRequestValidationType] = value;
}
}
[ConfigurationProperty("requestPathInvalidCharacters", DefaultValue = DefaultRequestPathInvalidCharacters)]
public string RequestPathInvalidCharacters {
get {
return (string)base[_propRequestPathInvalidCharacters];
}
set {
base[_propRequestPathInvalidCharacters] = value;
_RequestPathInvalidCharactersArray = null;
}
}
private int _MaxUrlLength = 0;
[ConfigurationProperty("maxUrlLength", DefaultValue = DefaultMaxUrlLength)]
[IntegerValidator(MinValue = 0)]
public int MaxUrlLength {
get {
if (_MaxUrlLength == 0)
_MaxUrlLength = (int)base[_propMaxUrlLength];
return _MaxUrlLength;
}
set {
_MaxUrlLength = value;
base[_propMaxUrlLength] = value;
}
}
private int _MaxQueryStringLength = 0;
[ConfigurationProperty("maxQueryStringLength", DefaultValue = DefaultMaxQueryStringLength)]
[IntegerValidator(MinValue = 0)]
public int MaxQueryStringLength {
get {
if (_MaxQueryStringLength == 0)
_MaxQueryStringLength = (int)base[_propMaxQueryStringLength];
return _MaxQueryStringLength;
}
set {
_MaxQueryStringLength = value;
base[_propMaxQueryStringLength] = value;
}
}
[ConfigurationProperty("relaxedUrlToFileSystemMapping", DefaultValue = DefaultRelaxedUrlToFileSystemMapping)]
public bool RelaxedUrlToFileSystemMapping {
get {
return (bool)base[_propRelaxedUrlToFileSystemMapping];
}
set {
base[_propRelaxedUrlToFileSystemMapping] = value;
}
}
[ConfigurationProperty("allowDynamicModuleRegistration", DefaultValue = DefaultAllowDynamicModuleRegistration)]
public bool AllowDynamicModuleRegistration {
get {
return (bool)base[_propAllowDynamicModuleRegistration];
}
set {
base[_propAllowDynamicModuleRegistration] = value;
}
}
private int BytesFromKilobytes(int kilobytes) {
long maxLength = kilobytes * 1024L;
return ((maxLength < Int32.MaxValue) ? (int)maxLength : Int32.MaxValue);
}
internal int MaxRequestLengthBytes {
get {
if (_MaxRequestLengthBytes < 0) {
_MaxRequestLengthBytes = BytesFromKilobytes(MaxRequestLength);
}
return _MaxRequestLengthBytes;
}
}
internal int RequestLengthDiskThresholdBytes {
get {
if (_RequestLengthDiskThresholdBytes < 0) {
_RequestLengthDiskThresholdBytes = BytesFromKilobytes(RequestLengthDiskThreshold);
}
return _RequestLengthDiskThresholdBytes;
}
}
internal String VersionHeader {
get {
if (!EnableVersionHeader) {
return null;
}
if (s_versionHeader == null) {
String header = null;
// construct once (race condition here doesn't matter)
try {
String version = VersionInfo.SystemWebVersion;
int i = version.LastIndexOf('.');
if (i > 0) {
header = version.Substring(0, i);
}
}
catch {
}
if (header == null) {
header = String.Empty;
}
s_versionHeader = header;
}
return s_versionHeader;
}
}
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
private char[] _RequestPathInvalidCharactersArray = null;
internal char[] RequestPathInvalidCharactersArray {
get {
if (_RequestPathInvalidCharactersArray != null)
return _RequestPathInvalidCharactersArray;
_RequestPathInvalidCharactersArray = DecodeAndThenSplitString(RequestPathInvalidCharacters);
if (_RequestPathInvalidCharactersArray == null) {
// Maybe comma was one of the invalid chars, which can cause DecodeAndThenSplitString to fail
// Split using the comma and then decode each part
_RequestPathInvalidCharactersArray = SplitStringAndThenDecode(RequestPathInvalidCharacters);
}
if (_RequestPathInvalidCharactersArray == null) { // failed to construct invalid chars
throw new ConfigurationErrorsException(SR.GetString(SR.Config_property_generic),
ElementInformation.Properties[_propRequestPathInvalidCharacters.Name].Source,
ElementInformation.Properties[_propRequestPathInvalidCharacters.Name].LineNumber);
}
return _RequestPathInvalidCharactersArray;
}
}
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
private static char[] DecodeAndThenSplitString(string invalidCharString) {
if (string.IsNullOrEmpty(invalidCharString)) {
return new char[0];
}
string[] stringsDecoded = HttpUtility.UrlDecode(invalidCharString, Encoding.UTF8).Split(',');
char[] charsDecoded = new char[stringsDecoded.Length];
for (int iter = 0; iter < stringsDecoded.Length; iter++) {
string decodedString = stringsDecoded[iter].Trim();
if (decodedString.Length == 1)
charsDecoded[iter] = decodedString[0];
else
return null; // failed
}
return charsDecoded;
}
//////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////
private static char[] SplitStringAndThenDecode(string invalidCharString) {
if (string.IsNullOrEmpty(invalidCharString)) {
return new char[0];
}
string[] stringsToDecode = invalidCharString.Split(',');
char[] charsDecoded = new char[stringsToDecode.Length];
for (int iter = 0; iter < stringsToDecode.Length; iter++) {
string decodedString = HttpUtility.UrlDecode(stringsToDecode[iter], Encoding.UTF8).Trim();
if (decodedString.Length == 1)
charsDecoded[iter] = decodedString[0];
else
return null; // failed
}
return charsDecoded;
}
// This is called as the last step of the deserialization process before the newly created section is seen by the consumer.
// We can use it to change defaults on-the-fly.
protected override void SetReadOnly() {
// Unless overridden, set <httpRuntime requestValidationMode="4.5" />
ConfigUtil.SetFX45DefaultValue(this, _propRequestValidationMode, VersionUtil.Framework45);
base.SetReadOnly();
}
}
}
|