@Neerav Agrawal apologize for the delay in my response. You might have missed to attach the output what you are getting.
Custom error pages are for errors that terminate on the FrontEnd (ie, request that doesn't make to your app). In this sense a 404-error page is not meaningful, since when a 404 comes from the FrontEnd it means we were unable to find a site for a hostname in the first place!
Once the request gets to the app it is assumed the customer can use whatever error page they want.
I have written the below custom error config in my web.config
file and test it as well. All the requests coming to the root url of the webapp it is showing the default page if we request to the path which doesnt exists in my application. it is redirecting the content in 404.html file. As shown below.
<configuration>
<system.webServer>
<httpErrors errorMode="Custom" defaultResponseMode="ExecuteURL">
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" path="/404.html" responseMode="ExecuteURL" />
</httpErrors>
</system.webServer>
</configuration>