The main technical points for customizing error pages in Asp.net mvc3 are. add the following nodes in config (specify the page to which an error is redirected), and create the corresponding action in the corresponding controller to point to the corresponding view.
Nodes added in Web. config:
<Customerrors mode ="On"Defaultredirect ="~ /Error"> <Error statuscode ="404"Redirect ="~ /Errors/error404"/> </Customerrors>
See a simple controllerCode:
Public ClassErrorscontroller: controller {////Get:/errors/PublicActionresult index (){ReturnView ();}PublicActionresult error404 (){ReturnView ();}}
Similar nodes exist in pure Asp.net, as shown below:
<Configuration> <system. Web> <customerrors defaultredirect ="Genericerror.htm"Mode ="Remoteonly"> <Error statuscode ="500"Redirect ="Internalerror.htm"/> </Customerrors> </system. Web> </configuration>