當前位置: 首頁>>代碼示例>>C#>>正文


C# Mvc.ActionExecutedContext類代碼示例

本文整理匯總了C#中System.Web.Mvc.ActionExecutedContext的典型用法代碼示例。如果您正苦於以下問題:C# ActionExecutedContext類的具體用法?C# ActionExecutedContext怎麽用?C# ActionExecutedContext使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


ActionExecutedContext類屬於System.Web.Mvc命名空間,在下文中一共展示了ActionExecutedContext類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: OnActionExecuted

 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     var categories = Repository.FindAll<Category>();
     var selectListItems = MappingEngine.Map<IEnumerable<Category>, IEnumerable<SelectListItem>>(categories);
     var controllerBase = filterContext.Controller;
     controllerBase.ViewData.Add(selectListItems);
 }
開發者ID:antgerasim,項目名稱:RealWorldMvc,代碼行數:7,代碼來源:RequriesCategoryListAttribute.cs

示例2: OnActionExecuted

        public override void OnActionExecuted(
                ActionExecutedContext filterContext)
        {
            if (filterContext == null)
                throw new ArgumentNullException("filterContext");

            //
            // see if this request included a "callback" querystring
            // parameter
            //
            string callback = filterContext.HttpContext.
                      Request.QueryString["callback"];
            if (callback != null && callback.Length > 0)
            {
                //
                // ensure that the result is a "JsonResult"
                //
                JsonResult result = filterContext.Result as JsonResult;
                if (result == null)
                {
                    throw new InvalidOperationException(
                        @"JsonpFilterAttribute must be applied only
                        on controllers and actions that return a
                        JsonResult object.");
                }

                filterContext.Result = new JsonpResult
                {
                    ContentEncoding = result.ContentEncoding,
                    ContentType = result.ContentType,
                    Data = result.Data,
                    Callback = callback
                };
            }
        }
開發者ID:the404,項目名稱:bigline,代碼行數:35,代碼來源:JsonpFilterAttribute.cs

示例3: EmptyResult

        void IActionFilter.OnActionExecuted(ActionExecutedContext aec)
        {
            var vr = aec.Result as ViewResult;
            var aof = aec.RouteData.Values["alternateOutputFormat"] as String;

            if (_requestSourceRestriction == RequestSourceRestriction.DenyRemoteRequests && !aec.RequestContext.HttpContext.Request.IsLocal)
            {
                aec.Result = new EmptyResult();
            }
            else
            {
                if (vr != null) switch (aof)
                {
                    case "json": aec.Result = new JsonResult
                    {
                        JsonRequestBehavior = _jsonRequestBehavior,
                        ContentType = "application/json",
                        ContentEncoding = Encoding.UTF8,
                        Data = vr.ViewData.Model
                    };
                    break;

                    case "txt": aec.Result = new ContentResult
                    {
                        Content = "Not yet implemented",
                        ContentType = "text/plain",
                        ContentEncoding = Encoding.UTF8,
                    };
                    break;
                }
            }
        }
開發者ID:roosteronacid,項目名稱:madtastisk,代碼行數:32,代碼來源:AlternateOutputAttribute.cs

示例4: OnActionExecuted

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            base.OnActionExecuted(filterContext);

            string _isMobileCheckParams = filterContext.HttpContext.Request.Params["isMobile"];
            string _userAgent = filterContext.HttpContext.Request.UserAgent;

            if (string.IsNullOrWhiteSpace(_isMobileCheckParams) || !_isMobileCheckParams.ToUpper().Equals("Y"))
            {
                if (!(IsAppleDevice(_userAgent) || IsAndroidDevice(_userAgent)))
                {
                    if (string.IsNullOrEmpty(RedirectUrl))
                    {
                        //throw new Exception("Mobile only!!");
                        var _errorMessage = new string[]
                    {
                        "mobile only",
                        filterContext.HttpContext.Request.Url.AbsoluteUri
                    };

                        string _model = new System.Web.Script.Serialization.JavaScriptSerializer().Serialize(_errorMessage);
                        filterContext.Result = new RedirectToRouteResult(
                            new System.Web.Routing.RouteValueDictionary { { "controller", "Error" }, { "model", _model } }
                        );
                    }
                    else
                    {
                        filterContext.HttpContext.Response.Redirect(RedirectUrl);
                    }

                }
            }
        }
開發者ID:jaecheol-jeong,項目名稱:NewsReaderTest,代碼行數:33,代碼來源:MobileOnlyAttribute.cs

示例5: OnActionExecuted

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            UserModel userModel;
            if (filterContext.Controller.ViewBag.UserModel == null)
            {
                userModel = new UserModel();
                filterContext.Controller.ViewBag.UserModel = userModel;
            }
            else
            {
                userModel = filterContext.Controller.ViewBag.UserModel as UserModel;
            }
            if (filterContext.HttpContext.User.Identity.IsAuthenticated)
            {
                YiHeUser yiheUser = filterContext.HttpContext.User.GetYiHeUser();
                if (userModel != null)
                {
                    userModel.IsUserAuthenticated = yiheUser.IsAuthenticated;
                    userModel.UserName = yiheUser.DisplayName;
                    userModel.RoleName = yiheUser.RoleName;
                }
            }

            base.OnActionExecuted(filterContext);
        }
開發者ID:luowei98,項目名稱:YiHe,代碼行數:25,代碼來源:UserFilter.cs

示例6: TranslateMessages

 private void TranslateMessages(ActionExecutedContext filterContext)
 {
     if (filterContext.Controller.ViewData.ContainsKey("Messages"))
     {
         MessageViewData messageViewData = (MessageViewData) filterContext.Controller.ViewData["Messages"];
         foreach (KeyValuePair<string, IList<string>> messagesForType in messageViewData.Messages)
         {
             for (int i = 0; i < messagesForType.Value.Count; i++)
             {
                 string baseName = String.Format("{0}.globalresources"
                     , filterContext.Controller.GetType().Namespace.Replace(".Controllers", String.Empty).ToLowerInvariant());
                 string originalMessage = messagesForType.Value[i];
                 string translatedMessage = this._localizer.GetString(originalMessage, baseName);
                 if (translatedMessage != originalMessage)
                 {
                     messagesForType.Value[i] = translatedMessage;
                     // Change the key of the messageParams if there were params for the original key
                     if (messageViewData.MessageParams.ContainsKey(originalMessage))
                     {
                         messageViewData.MessageParams.Add(translatedMessage, messageViewData.MessageParams[originalMessage]);
                         messageViewData.MessageParams.Remove(originalMessage);
                     }
                 }
             }
         }
     }
 }
開發者ID:xwyangjshb,項目名稱:cuyahoga,代碼行數:27,代碼來源:LocalizationFilter.cs

示例7: OnActionExecuted

 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     //_logger.InfoFormat(CultureInfo.InvariantCulture,
     //    "Executed action {0}.{1}",
     //    filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
     //    filterContext.ActionDescriptor.ActionName);
 }
開發者ID:nathanbedford,項目名稱:ScaffR-Generated,代碼行數:7,代碼來源:LogFilter.cs

示例8: OnActionExecuted

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var sessionController = filterContext.Controller as SessionController;
            if (sessionController == null)
            {
                return;
            }

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

                if (!session.Transaction.IsActive)
                {
                    return;
                }

                if (filterContext.Exception != null)
                {
                    session.Transaction.Rollback();
                }
                else
                {
                    session.Transaction.Commit();
                }
            }
        }
開發者ID:merwan,項目名稱:planning_dotnet,代碼行數:30,代碼來源:NHibernateActionFilter.cs

示例9: OnActionExecuted

 protected override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     Log.InfoFormat("Done executing {0}.{1}.",
         filterContext.ActionDescriptor.ControllerDescriptor.ControllerName,
         filterContext.ActionDescriptor.ActionName
     );
 }
開發者ID:Niels-V,項目名稱:Glimpse.Log4Net,代碼行數:7,代碼來源:HomeController.cs

示例10: OnActionExecuted

 public override void OnActionExecuted(ActionExecutedContext filterContext)
 {
     var modelState = filterContext.Controller.ViewData.ModelState;
     if ((filterContext.Result is RedirectToRouteResult || filterContext.Result is RedirectResult) && !modelState.IsValid)
         filterContext.Controller.TempData.Add(flashkey, modelState);
     base.OnActionExecuted(filterContext);
 }
開發者ID:ToJans,項目名稱:MVCExtensions,代碼行數:7,代碼來源:FlashInvalidModelStateAttribute.cs

示例11: OnActionExecuted

 /// <summary>
 /// Minification at the and of the request
 /// </summary>
 public void OnActionExecuted( ActionExecutedContext filterContext )
 {
     if ( IsSupportedContentType( filterContext ) )
     {
         filterContext.HttpContext.Response.Filter = new HtmlMinifyStream( filterContext.HttpContext.Response.Filter );
     }
 }
開發者ID:BenjaminAbt,項目名稱:samples.ASPNETMVC,代碼行數:10,代碼來源:HtmlMinimyFilter.cs

示例12: OnActionExecuted

 /// <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 OnActionExecuted(ActionExecutedContext filterContext)
 {
     var backOfficeController = GetController(filterContext.Controller);
     if (!backOfficeController.Notifications.Any())
         return;
     base.OnActionExecuted(filterContext);
 }
開發者ID:paulsuart,項目名稱:rebelcmsxu5,代碼行數:11,代碼來源:SupportsClientNotificationsAttribute.cs

示例13: OnActionExecuted

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            // After controller logic
            base.OnActionExecuted(filterContext);

            filterContext.HttpContext.Response.Write(this.Msg);
        }
開發者ID:Hagge,項目名稱:Mvc4Search,代碼行數:7,代碼來源:MyCustomActionFilter.cs

示例14: OnActionExecuted

        public override void OnActionExecuted(ActionExecutedContext filterContext)
        {
            var request = filterContext.HttpContext.Request;
            string controllerName = filterContext.ActionDescriptor.ControllerDescriptor.ControllerName;
            string actionName = filterContext.ActionDescriptor.ActionName;

            //Generate an audit
            AuditModel audit = new AuditModel()
            {
                //Your Audit Identifier
                AuditID = Guid.NewGuid(),
                //Our Username (if available)
                UserName = (request.IsAuthenticated) ? filterContext.HttpContext.User.Identity.Name : "Anonymous",
                //The IP Address of the Request
                IPAddress = request.ServerVariables["HTTP_X_FORWARDED_FOR"] ?? request.UserHostAddress,
                //The URL that was accessed
                AreaAccessed = request.RawUrl,
                //Creates our Timestamp
                TimeAccessed = DateTime.UtcNow,
                //controller and action
                Action = string.Format("Controller: {0} | Action: {1}", controllerName, actionName),
                //result
                Result = GetResult(filterContext.Result)
            };

            this.activityLogsService.CreateAuditLog(audit.UserName, audit.IPAddress, audit.AreaAccessed, audit.TimeAccessed, audit.Action, audit.Result);
        }
開發者ID:jfvaleroso,項目名稱:WMS_Revised,代碼行數:27,代碼來源:AuditAttribute.cs

示例15: JsReportStream

 public JsReportStream(ActionExecutedContext context, EnableJsReportAttribute attr, Func<ActionExecutedContext, EnableJsReportAttribute, string, Task<Report>> renderReport)
 {
     _stream = context.HttpContext.Response.Filter;
     _context = context;
     _attr = attr;
     _renderReport = renderReport;
 }
開發者ID:vasistbhargav,項目名稱:net,代碼行數:7,代碼來源:JsReportStream.cs


注:本文中的System.Web.Mvc.ActionExecutedContext類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。