Pregunta

I’ve got a Classic ASP application running on IIS (6/7) servers. When a page is requested that won’t be accessible any longer, I want to send a Response.Status = "410 Gone" but still deliver some sort of ErrorDocument. It seems that browsers halt retrieving as soon as they get a 410.

Except for IE, all browsers display the same “The page you requested was removed”, so I guess it’s a server setting. In .NET, there seems to be TrySkipIisCustomErrors, but for Classic ASP, I’m actually quite confident it’s anywhere in the Error Pages feature in IIS Manager.

Can I tell my IIS to still deliver content, even when the actual URI is gone?

¿Fue útil?

Solución

In your web application’s root directory, you have to add an attribute in the web.config file:

<system.webServer>
    <httpErrors existingResponse="PassThrough">
        …
    </httpErrors>
<system.webServer>

With existingResponse set to PassThrough, the response will be delivered if an existing response exists. There’s a nice article on HTTP Errors at www.iis.net.

There doesn’t need to be an <error> element, especially none on status code 410 (but of course you may add one).

Otros consejos

You could place a classic ASP page there that delivers the content and HTTP Status Code you want.

I tested this on IIS 7.5 with following code:

    <% Response.Status = "410 Gone" %>
    <html>
    <body>
    <h1>this is my content</h1>
    </body>
    </html>

Firefox shows the content as is, not a generic error page.

Update:

You will have to disable custom errors for this to work. You can do this by adding following line to your web.config (into section configuration/system.web):

<customErrors mode="Off" />

Otherwise, the default error page overrules your output. Classic ASP really doesn't seem to have anything like TrySkipIisCustomErrors.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top