Click here to Skip to main content
15,902,893 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
I want to avoid IIS and version disclosure during HTTP 404 not found error response in c#.

What I have tried:

I have set enableversionheader as false in the config file. Added URL Rewrite
            <rule name="ChangeServerHeader">
                <match serverVariable="RESPONSE_SERVER" pattern=".*" />
                <action type="Rewrite" value="Private Server" />

Also in the global.asax file have set code to remove the server header
protected void Application_PreSendRequestHeaders(object sender, EventArgs e)
     var app = sender as HttpApplication;
     if (app != null && app.Context != null)
Updated 6-Feb-23 3:17am
Andre Oosthuizen 6-Feb-23 9:46am    
Some solutions found at -

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900