Beispiel #1
0
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     Logger.DebugFormat(
         "El resultado fue {0}",
         filterContext.Result.ToString());
     base.OnResultExecuted(filterContext);
 }
        /// <summary>
        /// Called by the ASP.NET MVC framework after the action result executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            if (filterContext != null)
            {
                base.OnResultExecuted(filterContext);

                var context = filterContext.HttpContext;
                if (context != null && context.Response != null)
                {
                    var viewResult = filterContext.Result as ViewResultBase;

                    if (viewResult != null)
                    {
                        var builtView = viewResult.View as BuildManagerCompiledView;
                        if (builtView != null)
                        {
                            var cacheDependency = this.GetCacheDependency(builtView.ViewPath);
                            if (cacheDependency != null)
                            {
                                context.Response.AddCacheDependency(cacheDependency);
                            }
                        }
                    }
                }
            }
        }
 public void OnResultExecuted(ResultExecutedContext filterContext)
 {
     timer.Stop();
     filterContext.HttpContext.Response.Write(
             string.Format("<div>Result elapsed time: {0:F6}</div>",
                 timer.Elapsed.TotalSeconds));
 }
        public void OnResultExecuted(ResultExecutedContext filterContext)
        {
            // Don't show filter multiple times when using Html.RenderAction or Html.Action.
            if (filterContext.IsChildAction == true)
                return;

            var renderTimer = GetTimer(filterContext, render);
            renderTimer.Stop();

            var actionTimer = GetTimer(filterContext, action);
            var response = filterContext.HttpContext.Response;

            var txt = String.Format(
                "<hr /><h5>Action '{0} :: {1}' took {2}ms to execute and {3}ms to render.</h5>",
                filterContext.RouteData.Values["controller"],
                filterContext.RouteData.Values[action],
                actionTimer.ElapsedMilliseconds,
                renderTimer.ElapsedMilliseconds
                );

            if (response.ContentType == "text/html")
                response.Write(txt);
            else
                Debug.WriteLine(txt);
        }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            base.OnResultExecuted(filterContext);
#if Page_Trace
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
#endif
            if (Page_Context.Current.PageRequestContext != null)
            {

                var site = Page_Context.Current.PageRequestContext.Site;
                var page = Page_Context.Current.PageRequestContext.Page.AsActual();
                if (!filterContext.HttpContext.User.Identity.IsAuthenticated && page.EnabledCache)
                {
                    var outputTextWriterWrapper = filterContext.HttpContext.Response.Output as OutputTextWriterWrapper;
                    if (outputTextWriterWrapper != null
                        && filterContext.Exception == null
                        && filterContext.HttpContext.Response.ContentType.ToLower().Contains("text/html"))
                    {
                        var cacheKey = GetOutputCacheKey(filterContext.HttpContext, page);
                        if (outputTextWriterWrapper != null && site.ObjectCache().Get(cacheKey) == null)
                        {
                            site.ObjectCache().Add(cacheKey, outputTextWriterWrapper.ToString(), page.AsActual().OutputCache.ToCachePolicy());
                        }
                    }
                }

            }

#if Page_Trace
            stopwatch.Stop();
            filterContext.HttpContext.Response.Write(string.Format("OutputCacheFilterAttribute.OnResultExecuted, {0}ms.</br>", stopwatch.ElapsedMilliseconds));
#endif
        }
		public override void OnResultExecuted(ResultExecutedContext filterContext)
		{
			base.OnResultExecuted(filterContext);

			ContentType = ContentType ?? "text/html";
			filterContext.HttpContext.Response.ContentType = ContentType;
		}
 public static void Reset()
 {
     LastRequestData.ActionExecutedContext = null;
     LastRequestData.ResultExecutedContext = null;
     LastRequestData.HttpSessionState = null;
     LastRequestData.Response = null;
 }
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     base.OnResultExecuted(filterContext);
     var infoObject = (InfoObject)filterContext.RequestContext.HttpContext.Request.RequestContext.RouteData.DataTokens[profile];
     infoObject.ResultExecuted = (int)((Stopwatch)filterContext.RequestContext.HttpContext.Request.RequestContext.RouteData.DataTokens[stopwatch]).ElapsedMilliseconds;
     _bag.Add(infoObject);
 }
        /// <summary>
        /// Called by the ASP.NET MVC framework after the action result executes.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            base.OnResultExecuted(filterContext);

            AdminBaseController.CurrentEnvironment = null;
            AdminBaseController.CurrentController = null;
        }
Beispiel #10
0
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     string contentType = filterContext.HttpContext.Response.ContentType;
     if (contentType == "application/json")
         filterContext.HttpContext.Response.ContentType = "text/html";
     base.OnResultExecuted(filterContext);
 }
Beispiel #11
0
 protected override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     timer.Stop();
     filterContext.HttpContext.Response.Write(
         string.Format("<div>Total elapsed time: {0}</div>",
         timer.Elapsed.TotalSeconds));
 }
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     timer.Stop();
     filterContext.HttpContext.Response.Write(
         string.Format("Action result elapsed time: {0}",
             timer.Elapsed.TotalSeconds));
 }
        public override void OnResultExecuted(ResultExecutedContext context)
        {
            var resultType = context.Result.GetType().Name;
            LogManager.GetLogger("").Info("ResultExecuted: " + context.Controller + " ⇒ " + resultType);

            base.OnResultExecuted(context);
        }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            base.OnResultExecuted(filterContext);

            if (!IsEnable)
                return;

            if (filterContext.IsChildAction)
                return;

            if (filterContext.Exception != null || filterContext.HttpContext.Error != null)
                return;

            HttpRequestBase request = filterContext.HttpContext.Request;
            string acceptEncoding = request.Headers["Accept-Encoding"];
            if (string.IsNullOrEmpty(acceptEncoding))
                return;

            acceptEncoding = acceptEncoding.ToUpperInvariant();
            HttpResponseBase response = filterContext.HttpContext.Response;

            //if (response.IsRequestBeingRedirected)
            //    return;

            if (acceptEncoding.Contains("GZIP"))
            {
                response.AppendHeader("Content-encoding", "gzip");
                response.Filter = new GZipStream(response.Filter, CompressionMode.Compress);
            }
            else if (acceptEncoding.Contains("DEFLATE"))
            {
                response.AppendHeader("Content-encoding", "deflate");
                response.Filter = new DeflateStream(response.Filter, CompressionMode.Compress);
            }
        }
        public void OnResultExecuted(ResultExecutedContext filterContext)
        {
            foreach (var sitePart in _orchardServices.WorkContext.CurrentSite.ContentItem.Parts)
            {
                foreach (var property in sitePart.GetType().GetProperties().Where(p=>p.Name!="Id"))//id will always be 1 because this part is bound to the site
                {
                    try {
                        var propertyType = property.PropertyType;
                        // Supported types (we also know they are not indexed properties).
                        if ((propertyType == typeof (string) || propertyType == typeof (bool) || propertyType == typeof (int))
                            && property.CanRead) {
                            var value = property.GetValue(sitePart, null);

                            _performanceMonitor.PublishMessage(new SiteSettingsMessage {
                                Part = sitePart.PartDefinition.Name,
                                Name = property.Name,
                                Value = value
                            });
                        }
                    }
                    catch (Exception ex) {
                        //todo: figure out why this occaisionally fails
                    }
                }
            }
        }
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     MonitorLog MonLog = filterContext.Controller.ViewData[Key] as MonitorLog;
     MonLog.ExecuteEndTime = DateTime.Now;
     LoggerHelper.Monitor(MonLog.GetLoginfo(MonitorLog.MonitorType.View));
     filterContext.Controller.ViewData.Remove(Key);
 }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            //在Result执行之后
            //filterContext.HttpContext.Response.Write(@"<br />After ViewResult execute" + "\t " + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss:fffff"));

            var renderTimer = GetTimer(filterContext, "render");
            renderTimer.Stop();

            var actionTimer = GetTimer(filterContext, "action");
            var response = filterContext.HttpContext.Response;

            if (response.ContentType == "text/html")
            {
                //response.Write(
                //    string.Format(
                //        "<p>action '{0} :: {1}', execute: {2}ms, render: {3}ms.</p>",
                //        filterContext.RouteData.Values["controller"],
                //        filterContext.RouteData.Values["action"],
                //        actionTimer.ElapsedMilliseconds,
                //        renderTimer.ElapsedMilliseconds
                //    )
                //);
                response.Headers.Add("PageTime",
                    string.Format("Page Time Consuming {0}ms   Render Time Consuming  {1}ms", actionTimer.ElapsedMilliseconds, renderTimer.ElapsedMilliseconds));

            }

            base.OnResultExecuted(filterContext);
        }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            //We might want to close sessions even if we aren't delegated transaction support
            if (_delegateTransactionSupport) return;

            _dbContext.CloseSession();
        }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            string effectiveFactoryKey = GetEffectiveFactoryKey();

            ITransaction currentTransaction =
                NHibernateSession.CurrentFor(effectiveFactoryKey).Transaction;

            base.OnResultExecuted(filterContext);
            try
            {
                if (currentTransaction.IsActive) {
                    if ((filterContext.Exception != null) && (!filterContext.ExceptionHandled))
                    {
                        currentTransaction.Rollback();
                    }
                    else
                    {
                        currentTransaction.Commit();
                    }
                }
            }
            finally
            {
                currentTransaction.Dispose();
            }
        }
 public static void Reset()
 {
     ActionExecutedContext = null;
       ResultExecutedContext = null;
       HttpSessionState = null;
       Response = null;
 }
 /// <summary>
 /// OnResultExecuted
 /// </summary>
 /// <param name="filterContext"><see cref="ResultExecutedContext"/></param>
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     if (Apply(filterContext.RequestContext.RouteData.GetRequiredString("action")))
     {
         SessionManager.Unbind();
     }
 }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            base.OnResultExecuted(filterContext);
            #if Page_Trace
            Stopwatch stopwatch = new Stopwatch();
            stopwatch.Start();
            #endif
            if (Page_Context.Current.PageRequestContext != null)
            {

                var site = Page_Context.Current.PageRequestContext.Site;
                var page = Page_Context.Current.PageRequestContext.Page.AsActual();

                var outputTextWriterWrapper = filterContext.HttpContext.Response.Output as OutputTextWriterWrapper;
                if (outputTextWriterWrapper != null
                    && !(filterContext.Result is CachedContentResult)
                    && filterContext.Exception == null
                    && filterContext.HttpContext.Response.ContentType.ToLower().Contains("text/html"))
                {
                    var html = outputTextWriterWrapper.ToString();
                    var htmlParser = Kooboo.CMS.Common.Runtime.EngineContext.Current.TryResolve<IHtmlParser>();
                    if (htmlParser != null)
                    {
                        html = htmlParser.Parse(html);
                        outputTextWriterWrapper.Flush();
                        outputTextWriterWrapper.Write(html);
                    }
                }
            }

            #if Page_Trace
            stopwatch.Stop();
            filterContext.HttpContext.Response.Write(string.Format("PageHtmlParserActionFilter.OnResultExecuted, {0}ms.</br>", stopwatch.ElapsedMilliseconds));
            #endif
        }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            // After View Rendering logic
            base.OnResultExecuted(filterContext);

            filterContext.HttpContext.Response.Write(this.Msg);
        }
 /// <summary>
 /// Ensures that the controller is of the required type, if so lets execution continue on the base class
 /// </summary>
 /// <param name="filterContext"></param>
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     var backOfficeController = GetController(filterContext.Controller);
     if (!backOfficeController.Notifications.Any())
         return;
     base.OnResultExecuted(filterContext);
 }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            var controller = filterContext.Controller as SessionController;
            if( controller==null )
            {
                return;
            }

            using(var session = controller.Session)
            {
                if( session==null )
                {
                    return;
                }

                using(var transaction = session.Transaction)
                {
                    if( transaction==null || !transaction.IsActive )
                    {
                        return;
                    }

                    if( filterContext.Exception!=null )
                    {
                        transaction.Rollback();
                    }
                    else
                    {
                        transaction.Commit();
                    }
                    transaction.Dispose();
                }
            }
        }
        protected override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            if (_resultExecutingToExecuted != null)
                _resultExecutingToExecuted.Dispose();

            base.OnResultExecuted(filterContext);
        }
		public void Should_delegate_to_result_filter_executed()
		{
			var attribute = new FilterUsingAttribute(typeof(TestResultFilter));
			var context = new ResultExecutedContext();
			attribute.OnResultExecuted(context);
			context.Result.ShouldBe<EmptyResult>();
		}
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     if (filterContext.Exception != null)
     {
         filterContext.HttpContext.Response.Filter = null;
     }
 }
Beispiel #29
0
 public override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     base.OnResultExecuted(filterContext);
     if (Page_Context.Current.PageRequestContext != null)
     {
         var site = Page_Context.Current.PageRequestContext.Site;
         var page = Page_Context.Current.PageRequestContext.Page.AsActual();
         if (!filterContext.HttpContext.Request.IsAjaxRequest() && !filterContext.HttpContext.User.Identity.IsAuthenticated && page.CacheToDisk)
         {
             var outputTextWriterWrapper = filterContext.HttpContext.Response.Output as OutputTextWriterWrapper;
             if (outputTextWriterWrapper != null
                 && filterContext.Exception == null
                 && filterContext.HttpContext.Response.ContentType.ToLower().Contains("text/html"))
             {
                 try
                 {
                     var html = outputTextWriterWrapper.ToString();
                     PageCachingManager.AddCaching(filterContext.HttpContext, page, html);
                 }
                 catch (Exception e)
                 {
                     Kooboo.HealthMonitoring.Log.LogException(e);
                 }
             }
         }
     }
 }
        public override void OnResultExecuted(ResultExecutedContext filterContext)
        {
            var currentThreadId = System.Threading.Thread.CurrentThread.ManagedThreadId;
            if (!_start.ContainsKey(currentThreadId)) return;

            try
            {

                //计算出当前页面访问耗时
                var costSeconds = (DateTime.Now - _start[currentThreadId]).TotalSeconds;
                if (costSeconds > 2)//如果耗时超过2秒,就是用log4net打印出,具体是哪个页面访问超过了2秒,具体使用了多长时间。
                {
                    Logger.LogInfo(string.Format("Access the action more than 2 seconds. cost seconds {1}.  URL: {0}", _url[currentThreadId], costSeconds));
                }
            }
            catch (Exception ex)
            {
                Logger.LogError("TrackPageLoadPerformance : ", ex);
            }
            finally
            {
                _start.Remove(currentThreadId);
                _url.Remove(currentThreadId);
            }
        }
Beispiel #31
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="filterContext"></param>
        public override void OnResultExecuted(System.Web.Mvc.ResultExecutedContext filterContext)
        {
            base.OnResultExecuted(filterContext);

            // write to filterContext.Controller.TempData
            if (filterContext.Result is System.Web.Mvc.RedirectResult || filterContext.Result is System.Web.Mvc.RedirectToRouteResult || filterContext.Result is System.Web.Mvc.JsonResult)
            {
                filterContext.Controller.TempData[TempDataKEY] = Get().Where(x => x.IsRedirectMsg && x.IsRedirectActive).ToList();
            }
        }
Beispiel #32
0
        public override void OnResultExecuted(System.Web.Mvc.ResultExecutedContext filterContext)
        {
            ViewResult result = filterContext.Result as ViewResult;

            if (result != null)
            {
                SillyLogger.Store("Használt view neve: " + result.ViewName);
            }

            RazorView razor = result.View as RazorView;

            if (razor != null)
            {
                SillyLogger.Store("Használt view template: " + razor.ViewPath);
            }

            //var response = filterContext.HttpContext.Response;
            //response.Filter = new LogFilter(response.Filter, filterContext.RouteData.Values["action"].ToString());

            SillyLogger.Store(string.Format("{0} action and view processed", filterContext.RouteData.Values["action"]));
        }
Beispiel #33
0
 public void OnResultExecuted(System.Web.Mvc.ResultExecutedContext filterContext)
 {
 }
Beispiel #34
0
 /// <summary>
 /// 加载"视图" 后执行
 /// </summary>
 /// <param name="filterContext"></param>
 public override void OnResultExecuted(System.Web.Mvc.ResultExecutedContext filterContext)
 {
     filterContext.HttpContext.Response.Write("加载视图后执行 OnResultExecuted <br/>");
     base.OnResultExecuted(filterContext);
 }
Beispiel #35
0
 protected virtual void OnResultExecuted(ResultExecutedContext filterContext);
Beispiel #36
0
 void IResultFilter.OnResultExecuted(ResultExecutedContext filterContext);
Beispiel #37
0
 protected override void OnResultExecuted(ResultExecutedContext filterContext)
 {
     base.OnResultExecuted(filterContext);
 }
 public virtual void OnResultExecuted(ResultExecutedContext filterContext)
 {
 }