/// <summary> /// 加载action前 /// </summary> /// <param name="filterContext"></param> public override void OnActionExecuting(ActionExecutingContext filterContext) { base.OnActionExecuting(filterContext); if (filterContext.ActionDescriptor.GetCustomAttributes(typeof(NoFilter), false).Length == 0) { //启用noFilter特性的不统计 SaidRecordCommon.SetAdmindId(HttpContext.Current); SaidRecordCommon.Add(HttpContext.Current); } }
public ActionResult Cl(string url, string referrer = null) { //收集统计信息 string key = Request[SaidRecordCommon.KEY]; //修正 if (string.IsNullOrWhiteSpace(key)) { key = string.Empty; } //请求来源 Uri urlReferrer = null; //请求的url Uri requestUrl = null; //检测并修正来源 if (string.IsNullOrWhiteSpace(referrer) || !Uri.TryCreate(referrer, UriKind.RelativeOrAbsolute, out urlReferrer)) { urlReferrer = Request.UrlReferrer; } try { //检测请求的url是否合法 if (!Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out requestUrl)) { SaidRecordCommon.AddFail(key, url, urlReferrer == null ? null : urlReferrer.OriginalString); return(Redirect(url)); } url = UrlCommon.ResolveHTTPUri(url); //修正uri //检测通过 if (urlReferrer == null) { SaidRecordCommon.Add(key, url); } else { SaidRecordCommon.Add(key, url, urlReferrer); } } catch (Exception e) { logManager.Error(string.Format("跳转Error{0}【请求url】{1}", Environment.NewLine, url), e); } return(Redirect(url)); }