1

I need to make simple 404 error pages which may have some server side code. for that i have made web.config file as below

    <?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.asp" />
            </files>
        </defaultDocument>
        <httpErrors errorMode="Custom" existingResponse="Replace" defaultResponseMode="ExecuteURL">
            <remove statusCode="404" subStatusCode="-1" />
            <error statusCode="404" prefixLanguageFilePath="" path="404.asp" />
        </httpErrors>
    </system.webServer>
</configuration>

and 404.asp page has following code

404 page   
<%=date%>

when i request non existing page then it shows output as

404 page
<%=date%>

the asp code is sent to browser directly without executing on server side

how can i avoid this

1 Answers1

0

change defaultResponseMode="ExecuteURL" to defaultResponseMode="Redirect". Also use an absolute URL instead of 404.asp (e.g. http://example.com/404.asp)

Ali Sheikhpour
  • 10,475
  • 5
  • 41
  • 82