I successfully use a similar setup which I migrated from IIS 6 to IIS 7.
My web.config has the following section;
<system.webServer>
<httpErrors errorMode="Custom">
<remove statusCode="500" subStatusCode="-1" />
<remove statusCode="404" subStatusCode="-1" />
<error statusCode="404" prefixLanguageFilePath="" path="/302page.asp" responseMode="ExecuteURL" />
<error statusCode="500" prefixLanguageFilePath="" path="/500page.asp" responseMode="ExecuteURL" />
<error statusCode="500" subStatusCode="100" path="/500page.asp" responseMode="ExecuteURL" />
</httpErrors>
<system.webServer>
I configured this on the relevant site via IIS Manager but you could do it via web.config file if easier for you.
You can add conditional header depending on whether should be 301, 302 or 404.
404;
Response.Status = "404 Not Found"
Response.AddHeader "Location", pagename
302 (temporary re-direct);
Response.Status="301 Object Moved"
Response.AddHeader "Location", pagename
301 (permanent re-direct);
Response.Status="301 Moved Permanently"
Response.AddHeader "Location", pagename
IIS site's application pool uses Integrated pipeline-mode. And attached are settings for debugging section for site.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…