//获取自定义显示的出错信息
        protected virtual string GetDisplayMessage(HttpWebException ex)
        {
            var e          = ex.InnerException as HttpException;
            var statusCode = e != null?e.GetHttpCode().ToString() : null;              //获取HTTP状态

            var message = this.DefaultErrorMessage;

            if (string.IsNullOrEmpty(message))
            {
                message = "<h1>ERROR OCCURRED</h1><i>error code:{3}</i>";
            }
            message = string.Format(message, ex.InnerException.Message, ex.HttpAppInstance.Request.Url, ex.InnerException, statusCode);
            return(message);
        }
 //获取是否输出自定义信息,可根据访问者有选择的输出
 protected virtual bool IsCustomEnabled(HttpWebException ex)
 {
     //如果是本电脑访问,则输出详细信息
     if (ex.HttpAppInstance.Request.IsLocal)
     {
         return(false);
     }
     //判断来访者是否为本地
     if (this.customLocals != null && this.customLocals.Length > 0)
     {
         var ip = ex.HttpAppInstance.Request.UserHostAddress;
         if (this.customLocals.Any(ip.StartsWith))                  //IP地址是本地
         {
             return(false);
         }
     }
     return(this.CustomEnabled);
 }
Example #3
0
 //获取是否输出自定义信息,可根据访问者有选择的输出
 protected virtual bool IsCustomEnabled(HttpWebException ex)
 {
     //如果是本电脑访问,则输出详细信息
     if (ex.HttpAppInstance.Request.IsLocal) {
         return false;
     }
     //判断来访者是否为本地
     if (this.customLocals != null && this.customLocals.Length > 0) {
         var ip = ex.HttpAppInstance.Request.UserHostAddress;
         if (this.customLocals.Any(ip.StartsWith)) {//IP地址是本地
             return false;
         }
     }
     return this.CustomEnabled;
 }
Example #4
0
 //获取自定义显示的出错信息
 protected virtual string GetDisplayMessage(HttpWebException ex)
 {
     var e = ex.InnerException as HttpException;
     var statusCode = e != null ? e.GetHttpCode().ToString() : null;//获取HTTP状态
     var message = this.DefaultErrorMessage;
     if (string.IsNullOrEmpty(message)) {
         message = "<h1>ERROR OCCURRED</h1><i>error code:{3}</i>";
     }
     message = string.Format(message, ex.InnerException.Message, ex.HttpAppInstance.Request.Url, ex.InnerException, statusCode);
     return message;
 }