I have an Angular application hosted on IIS. In my application there is a custom 404 error page for incorrect urls. However, whenever a js file is requested from the url https://mywebsite.com/assets/js/Mordernizer.min.js (with .js extension), it displays IIS detailed error page, exposing physical directory of the application. When the URL is https://mywebsite.com/assets/js/Mordernizer.min (without .js extension), the custom error page works as expected.
Issue resolved! I just had to set httpErrors configuration in web.config file at Angular level (dist folder). All this time I was modifying the Asp.net Core application web.config file. Silly mistake, anyway thanks!