# 1.11.5.Custom Error Pages

* 1.Try to throw an exception

  ```
   public ActionResult About()
        {
            throw new Exception();

            return View();
        }
  ```
* 2.Edit web.config

  * RemoteOnly: when running on local site, it will turn off&#x20;

  ```
  <system.web>
    <!--<customErrors mode="RemoteOnly"></customErrors>-->
    <customErrors mode="On">
      <error statusCode="404" redirect="~/404.html"/>
    </customErrors>
  ```
* 3.Add 404.html

  ```
  <!DOCTYPE html>
  <html>
  <head>
    <meta charset="utf-8" />
    <title></title>
  </head>
  <body>
  <h1>Not found</h1>
  </body>
  </html>
  ```
* 4.Edit web.config

  ```
  <system.webServer>
    <httpErrors errorMode="Custom">
      <remove statusCode="404"/>
      <error statusCode="404" path="404.html" responseMode="File"/>
    </httpErrors>
  ```
