I have an asp.net
website and i am rying to configure a 404 page but i cant seem to get it working.
The code i have in my web.config is
<system.web>
<customErrors mode="On" defaultRedirect="ResponseRewrite">
<error statusCode="404" redirect="~/Page_Not_Found.aspx" />
</customErrors>
</system.web>
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="404"/>
<error statusCode="404" path="~/Page_Not_Found.aspx" responseMode="Redirect"/>
</httpErrors>
</system.webServer>
Error page HTML
<%@ Page Title="- Page not found" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Page_Not_Found.aspx.cs" Inherits="WebApplication1.Page_Not_Found" %>
<asp:Content ID="404BodyContent" ContentPlaceHolderID="MainContent" runat="server">
<div class="col-xs-12 col-sm-9">
<h1>Page not found</h1>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
<p>Use this area to provide additional information.</p>
</div>
</asp:Content>
When I enter and invalid URL i get the below server error
Server Error in '/' Application. Runtime Error Description: An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page for the first exception. The request has been terminated.
What am I doing wrong?
I have looked at other solutions on here and also on the web but all the fixes dont seem to help me.