2 // System.Web.Configuration.CustomErrorsSection
5 // Chris Toshok (toshok@ximian.com)
7 // (C) 2011 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.
32 using System.Configuration;
35 namespace System.Web.Configuration
37 public sealed class CustomErrorsSection : ConfigurationSection
39 static ConfigurationProperty defaultRedirectProp;
40 static ConfigurationProperty errorsProp;
41 static ConfigurationProperty modeProp;
42 static ConfigurationProperty redirectModeProp;
43 static ConfigurationPropertyCollection properties;
45 static CustomErrorsSection ()
47 defaultRedirectProp = new ConfigurationProperty ("defaultRedirect", typeof (string), null);
48 errorsProp = new ConfigurationProperty (String.Empty, typeof (CustomErrorCollection), null,
49 null, PropertyHelper.DefaultValidator,
50 ConfigurationPropertyOptions.IsDefaultCollection);
51 modeProp = new ConfigurationProperty ("mode", typeof (CustomErrorsMode), CustomErrorsMode.RemoteOnly,
52 new GenericEnumConverter (typeof (CustomErrorsMode)),
53 PropertyHelper.DefaultValidator,
54 ConfigurationPropertyOptions.None);
55 redirectModeProp = new ConfigurationProperty ("redirectMode", typeof (CustomErrorsRedirectMode), CustomErrorsRedirectMode.ResponseRedirect,
56 new GenericEnumConverter (typeof (CustomErrorsRedirectMode)),
57 PropertyHelper.DefaultValidator, ConfigurationPropertyOptions.None);
59 properties = new ConfigurationPropertyCollection ();
61 properties.Add (defaultRedirectProp);
62 properties.Add (errorsProp);
63 properties.Add (modeProp);
64 properties.Add (redirectModeProp);
68 protected internal override void DeserializeSection (XmlReader reader)
70 base.DeserializeSection (reader);
74 protected internal override void Reset (ConfigurationElement parentElement)
76 base.Reset (parentElement);
79 [ConfigurationProperty ("defaultRedirect")]
80 public string DefaultRedirect {
81 get { return (string) base [defaultRedirectProp];}
82 set { base[defaultRedirectProp] = value; }
85 [ConfigurationProperty ("", Options = ConfigurationPropertyOptions.IsDefaultCollection)]
86 public CustomErrorCollection Errors {
87 get { return (CustomErrorCollection) base [errorsProp];}
90 [ConfigurationProperty ("mode", DefaultValue = "RemoteOnly")]
91 public CustomErrorsMode Mode {
92 get { return (CustomErrorsMode) base [modeProp];}
93 set { base[modeProp] = value; }
96 [ConfigurationProperty ("redirectMode", DefaultValue = CustomErrorsRedirectMode.ResponseRedirect)]
97 public CustomErrorsRedirectMode RedirectMode {
98 get { return (CustomErrorsRedirectMode) base [redirectModeProp]; }
99 set { base [redirectModeProp] = value; }
102 protected internal override ConfigurationPropertyCollection Properties {
103 get { return properties; }