HandleError is an attribute.
Brief Introduction to Attributes
, , , , , , , . :
public class NameOfYourAttributeAttribute : Attribute {
}
, , :
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct)]
public class NameOfYourAttributeAttribute : Attribute {
}
, , . MSDN, Author (http://msdn.microsoft.com/en-us/library/z919e8tw%28v=vs .80%29.aspx):
[System.AttributeUsage(System.AttributeTargets.Class | System.AttributeTargets.Struct, AllowMultiple = true)]
public class Author : System.Attribute
{
string name;
public double version;
public Author(string name)
{
this.name = name;
version = 1.0;
}
public string GetName()
{
return name;
}
}
[Author("H. Ackerman")]
private class FirstClass
{
}
class TestAuthorAttribute
{
static void Main()
{
PrintAuthorInfo(typeof(FirstClass));
PrintAuthorInfo(typeof(SecondClass));
PrintAuthorInfo(typeof(ThirdClass));
}
private static void PrintAuthorInfo(System.Type t)
{
System.Console.WriteLine("Author information for {0}", t);
System.Attribute[] attrs = System.Attribute.GetCustomAttributes(t);
foreach (System.Attribute attr in attrs)
{
if (attr is Author)
{
Author a = (Author)attr;
System.Console.WriteLine(" {0}, version {1:f}", a.GetName(), a.version);
}
}
}
}
HandleError, :
, . HandleError , - , Error ~/Views/Shared/.
. http://msdn.microsoft.com/en-us/library/system.web.mvc.handleerrorattribute.aspx.