问题是404错误没有特殊的异常类,我得到常规的System.Web.HttpException,其中Message =“文件不存在”.
我应该只使用异常消息还是有更好的方法?
谢谢.
例如:
Exception ex = Server.GetLastError(); HttpException httpEx = ex as HttpException; if (httpEx != null && httpEx.GetHttpCode() == 404) { //do what you want for 404 errors }