I am trying to redirect user to an controller action while there is any 404 found. Like missing Controller or missing action or bad URL. I am using below approach :
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" />
<error statusCode="404" responseMode="ExecuteURL" path="/Error/PageNotFound" />
</httpErrors>
But the issues is my action(pageNotFound) is called every time I request a URL. Even if the URL is valid.This may kill performance during production deployment. Any suggestion or another approach