0
votes

On my web server, if i visit a page that does not exist, it generates a proper 404, UNLESS that page ends in .aspx. If the invalid url ends with .aspx, IIS generates the marker file error:

"This is a marker file generated by the precompilation tool, and should not be deleted!"

instead of a proper 404. How can i make IIS display/serve a 404 for unknown or invalid .aspx pages?

For example:

http://www.mysite.com/iDontExist.txt --> generates proper 404 http://www.mysite.com/iDontExist.aspx --> marker file error instead of 404

any ideas?

2

2 Answers

0
votes

You need to turn on the custome errors via the web.config

 <configuration>
  <system.web>
    <customErrors defaultRedirect="GenericError.html" mode="On">
      <error statusCode="404" redirect="PageNotFound.html"/>
    </customErrors>
  </system.web>
</configuration>

More information on this can be found in MSDN

0
votes

The trick was to set the "redirect mode" of the customErrors tag to 'ResponseRedirect' instead of 'ResponseRewrite':

<system.web>
    <customErrors mode="RemoteOnly" defaultRedirect="customError.aspx" redirectMode="ResponseRedirect">
        <error statusCode="404" redirect="customError404.aspx" />
        <error statusCode="500" redirect="customError500.aspx" />
    </customErrors>
</system.web>