Hi sds,
You need to set the location tag for allow access to anonymous users for error file.
<configuration>
<system.web>
<authentication mode="Windows" >
</authentication>
<authorization>
<deny users="?" />
</authorization>
</system.web>
<location path="error.htm">
<system.web>
<authorization>
<allow users ="*" />
</authorization>
</system.web>
</location>
</configuration>
For more details refer below link.
Authorization Permissions