在web.config的<system.web>下加上以下配置
<customErrors mode="On" defaultRedirect="MyErrorPage.html">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.html" />
</customErrors>
mode:开发时设置成On,发布时设置成RemoteOnly