How to Set Up .Net and HTTP Errors on Winhost

When setting up custom errors on Winhost it is important that you set up both .Net errors as well as HTTP errors. Failing to do so can lead to a custom error appearing for .aspx files, but not html or php files or vice versa.
 
Using IIS Manager:
 
For this method you will need IIS manager and need it connected to your site. If you do not follow theses instructions: https://support.winhost.com/kb/a628/using-the-microsoft-iis-manager.aspx
 
1) Once connected to IIS manager for your site double click on either .Net Error Pages or Error Pages
 
 
 
 
 
.Net Error Pages:
 
1) Click on Add on the right hand side.
2) Under the Status Code enter which status code you want to redirect. 
3)  Under Absolute URL will be the name of the custom error file you have on the server. For example 404.aspx.
4) Click OK
5) Then click on the new error page entry and then on the right side click Edit Feature Settings.
6) You'll want to change Mode to "On" and under default page put the default custom error page you would like.
 
 
 
 
 
IIS Error Pages:
 
1) You will see that the status codes have default error pages already set. Click on the status code you want to have custom and click edit on the right.
2)  On the pop-up screen click on the bubble for "Execute a URL on this site" and enter the name of your custom error file. For example /404.aspx or /404.html
3) Click OK
4) Then click on that same error code and on the right, click on "Edit Feature Settings"
5) Under "Error Responses" you'll want to click "Custom error pages" and you can set a default path if you wish.
 
 
 
 
Adding Custom Errors through the web.config:
 
For ASP.Net errors you'll want to enter the following code into your web.config file:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.web>
        <customErrors defaultRedirect="ERROR_FILE_NAME" mode="On">
            <error redirect="ERROR_FILE_NAME" statusCode="404" />
        </customErrors>
 </system.web>
</configuration>
For HTTP errors you will enter the following code into your web.config:
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
   <system.webServer>
        <httpErrors errorMode="Custom">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="/ERROR_FILE_NAME" 
                   responseMode="ExecuteURL" />
        </httpErrors>
   </system.webServer>
</configuration>
 
 
In both cases you will need to replace "ERROR_FILE_NAME" with the actual file name of your custom error. Also you will have to adjust the status code depending on which error code you want to catch.