Search Engine needs to know a file no longer exists in order to update indexes.
One way I tried was to include Response.StatusCode = 404 in the custom 404 error page’s Page_Load event, but the result was the custom page could not be loaded.
In the web.config file’s <customErrors> element, there is a statusCode attribute, is that a good way to inform the Search Engine about 404 status?
I would suggest you to add it in web.config
<customErrors><error....because it is easy to maintain in a file then doing inline coding in every page. One big winner if changes are required all you have to do is update the config file and just do a config release instead of the entire solution