• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# Mvc.ResultExecutingContext类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中System.Web.Mvc.ResultExecutingContext的典型用法代码示例。如果您正苦于以下问题:C# ResultExecutingContext类的具体用法?C# ResultExecutingContext怎么用?C# ResultExecutingContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



ResultExecutingContext类属于System.Web.Mvc命名空间,在下文中一共展示了ResultExecutingContext类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: OnResultExecuting

 public void OnResultExecuting(ResultExecutingContext filterContext) {
     // should only run on a full view rendering result
     if (!(filterContext.Result is ViewResult) || !Orchard.UI.Admin.AdminFilter.IsApplied(filterContext.RequestContext))
         return;
     _resourceManager.Require("script", "jQuery");
     _resourceManager.Include("script", "~/Modules/Orchard.MediaPicker/Scripts/MediaPicker.js", null);
 }
开发者ID:SunRobin2015,项目名称:RobinWithOrchard,代码行数:7,代码来源:AdminFilter.cs


示例2: OnResultExecuting

        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var viewResult = filterContext.Result as ViewResult;
            if (viewResult == null)
                return;

            var workContext = _workContextAccessor.GetContext(filterContext);

            if (workContext == null ||
                workContext.Layout == null ||
                workContext.CurrentSite == null ||
                AdminFilter.IsApplied(filterContext.RequestContext))
            {
                return;
            }

            var group = _deviceGroupService.GetCurrentGroup();
            if (group == null)
                return;

            if (group.Record.SwitcherEnabled && !string.IsNullOrWhiteSpace(group.Record.SwitcherText))
            {
                if (!string.IsNullOrWhiteSpace(group.Record.SwitcherZone))
                {
                    dynamic switcherShape = Shape.ThemeSwitcher_Links(SwitcherText: group.Record.SwitcherText);
                    var zone = workContext.Layout.Zones[group.Record.SwitcherZone];
                    zone.Add(switcherShape, group.Record.SwitcherPosition);
                }
            }
        }
开发者ID:jrestall,项目名称:Orchard.Mobile.Contrib,代码行数:30,代码来源:ThemeSwitchingAdaptation.cs


示例3: OnResultExecuting

        protected override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var trace = new MallBrowseTrace();
            trace.SourceOfPurchase();

            base.OnResultExecuting(filterContext);
        }
开发者ID:summer-breeze,项目名称:ChengGouHui,代码行数:7,代码来源:BaseController.cs


示例4: OnResultExecuting

        protected override void OnResultExecuting(ResultExecutingContext ctx)
        {
            base.OnResultExecuting(ctx);

            string _ipAddress;
            string _sessionId;
            _ipAddress = ctx.HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(_ipAddress))
            { _ipAddress = ctx.HttpContext.Request.ServerVariables["REMOTE_ADDR"]; }
            if (Request.Cookies["sessionKey"] != null)
            {
                _sessionId = Request.Cookies["sessionKey"].Value;
            }
            else
            {
                Response.Cookies.Add(new System.Web.HttpCookie("sessionKey", ctx.HttpContext.Session.SessionID));
                Response.Cookies["sessionKey"].Expires = DateTime.Now.AddHours(12);
                _sessionId = ctx.HttpContext.Session.SessionID;
            }

            Tracking track = new Tracking();
            track.IP = _ipAddress;
            track.Session = _sessionId;
            track.URL = ctx.HttpContext.Request.Url.PathAndQuery;
            track.CreatedDate = DateTime.Now;

            using (var db = new DIYFE.EF.DIYFEEntities())
            {
                db.Trackings.Add(track);
                db.SaveChanges();
            }

            ViewBag.PageModel = PageModel;
        }
开发者ID:sumdood31,项目名称:DIYFE,代码行数:34,代码来源:ApplicationController.cs


示例5: OnResultExecuting

 public void OnResultExecuting(ResultExecutingContext filterContext) {
     // should only run on a full view rendering result
     if (!(filterContext.Result is ViewResult) || !UI.Admin.AdminFilter.IsApplied(filterContext.RequestContext))
         return;
     _resourceManager.Include("stylesheet", "~/Modules/Orchard.MediaLibrary/Styles/dialog-mode.css", null);
     _resourceManager.Include("script", "~/Modules/Orchard.MediaLibrary/Scripts/modal-window.js", null);
 }
开发者ID:wezmag,项目名称:Coevery,代码行数:7,代码来源:ModalAdminFilter.cs


示例6: OnResultExecuting

        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var url = new UrlHelper(filterContext.RequestContext);
            var id = filterContext.RouteData.Values["id"];

            if (filterContext.Controller.GetType() == typeof(DataCollectionController))
            {
                var projectId = filterContext.RouteData.Values["projectId"];

                filterContext.Controller.ViewBag.Steps = new List<Step>
                                                             {
                                                                 new Step {Url = url.Action("Step1", "DataCollection", new {id, projectId}), Name = "Section 1"},
                                                                 new Step {Url = url.Action("Step2", "DataCollection", new {id, projectId}), Name = "Section 2"}
                                                             };
                filterContext.Controller.ViewBag.MaxStep = 2;
            }
            else if (filterContext.Controller.GetType() == typeof(ApprovalController))
            {
                filterContext.Controller.ViewBag.Steps = new List<Step>
                                                             {
                                                                 new Step {Url = url.Action("Step1", "Approval", new {id }), Name = "Section 1"},
                                                                 new Step {Url = url.Action("Step2", "Approval", new {id }), Name = "Section 2"},
                                                                 new Step {Url = url.Action("Confirm", "Approval", new {id}), Name = "Confirm"}
                                                             };
                filterContext.Controller.ViewBag.MaxStep = 2;
            }
        }
开发者ID:SharePointSusan,项目名称:Research-Data-Manager,代码行数:27,代码来源:ProvideDataCollectionStepsAttribute.cs


示例7: OnResultExecuting

        public void OnResultExecuting(ResultExecutingContext filterContext) 
        {

            // ignore filter on admin pages
            if (AdminFilter.IsApplied(filterContext.RequestContext)) 
                return;

            // should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult))
                return;

            var settings = _settingsService.GetSettings();

            if(String.IsNullOrEmpty(settings.AccentCss)) 
                return;

            var themeName = _siteThemeService.GetSiteTheme();
            if (themeName.Name == Constants.THEME_NAME)
            {
                var viewResult = filterContext.Result as ViewResult;
                if (viewResult == null)
                    return;

                if (settings.UseBranding) 
                {
                    /* TODO: Replace note use Items collection */
                    System.Web.HttpContext.Current.Items[Constants.ITEM_USE_BRANDING] = settings.UseBranding.ToString();
                    System.Web.HttpContext.Current.Items[Constants.ITEM_TAGLINE] = settings.Tagline;
                }
            }
        }
开发者ID:bkupev,项目名称:detached,代码行数:31,代码来源:BrandingFilter.cs


示例8: OnResultExecuting

        public override void OnResultExecuting(ResultExecutingContext context)
        {
            // if (!context.HttpContext.User.Identity.IsAuthenticated) return;
            // var uId = new CurrentUser(context.HttpContext).person.Id;
            var uname = context.HttpContext.User.Identity.Name;
            var request = context.HttpContext.Request;

            var refUrl = "";
            if (request.UrlReferrer != null) refUrl = request.UrlReferrer.ToString();

            PageRequest pv = new PageRequest
            {
                Name = request.RawUrl,
                Url = request.RawUrl,
                UrlReferrer = refUrl,
                UserIP = request.UserHostAddress,
                UserName = uname,
                // UserId = uId, CookieVal = reqInfo.Cookies["yourcookie"].Value,
                Created = ExtensionMethods.JsonDate(DateTime.Now),
                Action = (string)context.RequestContext.RouteData.Values["action"],
                Controller = (string)context.RouteData.Values["controller"],
                Param1 = (string)context.RouteData.Values["uref"],
                PageId = Convert.ToInt32(context.RouteData.Values["Id"]),
            };

            LogPageView(pv);
        }
开发者ID:bradoyler,项目名称:CloudMine-UserTracking-MVC,代码行数:27,代码来源:Global.asax.cs


示例9: OnResultExecuting

		public void OnResultExecuting(ResultExecutingContext filterContext)
		{
			if (!_profilerSettings.EnableMiniProfilerInPublicStore)
				return;
			
			// should only run on a full view rendering result
			var result = filterContext.Result as ViewResultBase;
			if (result == null)
			{
				return;
			}

			if (!this.ShouldProfile(filterContext.HttpContext))
			{
				return;
			}

			if (!filterContext.IsChildAction)
			{
				_widgetProvider.Value.RegisterAction(
					"head_html_tag",
					"MiniProfiler",
					"DevTools",
					new { area = "SmartStore.DevTools" });
			}

			var viewName = result.ViewName;
			if (viewName.IsEmpty())
			{
				string action = (filterContext.RouteData.Values["action"] as string).EmptyNull();
				viewName = action;
			}

			this._profiler.Value.StepStart("ResultFilter", string.Format("{0}: {1}", result is PartialViewResult ? "Partial" : "View", viewName));
		}
开发者ID:boatengfrankenstein,项目名称:SmartStoreNET,代码行数:35,代码来源:ProfilerFilter.cs


示例10: OnResultExecuting

        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            var context = filterContext.HttpContext;

            var ae = context.Request.Headers["Accept-Encoding"];
            if (ae != null)
            {
                ae = ae.ToLower();
                var response = context.Response;
                if (ae.Contains("gzip"))
                {
                    response.AddHeader("Content-Encoding", "gzip");
                    response.Filter =
                        new System.IO.Compression.GZipStream(response.Filter, System.IO.Compression.CompressionMode.Compress);
                }
                else if (ae.Contains("deflate"))
                {
                    response.AddHeader("Content-Encoding", "deflate");
                    response.Filter =
                        new System.IO.Compression.DeflateStream(response.Filter, System.IO.Compression.CompressionMode.Compress);
                }
            }

            base.OnResultExecuting(filterContext);
        }
开发者ID:neurospeech,项目名称:atoms-mvc.net,代码行数:25,代码来源:CompressionFilter.cs


示例11: OnResultExecuting

        //protected override void Initialize(System.Web.Routing.RequestContext requestContext)
        //{
        //    base.Initialize(requestContext);
        //    //ViewData["OpenTasks"] = DataContext.Tasks.Where(t => t.UserId == this.UserId).Count();
        //}
        protected override void OnResultExecuting(ResultExecutingContext ctx)
        {
            base.OnResultExecuting(ctx);

            //string sDbg = ctx.Controller.TempData["DebugTrc"] as string;
            //System.Diagnostics.Debug.WriteLine("OnResultExecuted " +
            //sDbg);

            string _ipAddress;
            string _sessionId;
            _ipAddress = ctx.HttpContext.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
            if (string.IsNullOrEmpty(_ipAddress))
            { _ipAddress = ctx.HttpContext.Request.ServerVariables["REMOTE_ADDR"]; }
            if (Request.Cookies["sessionKey"] != null)
            {
                _sessionId = Request.Cookies["sessionKey"].Value;
            }
            else
            {
                Response.Cookies.Add(new System.Web.HttpCookie("sessionKey", ctx.HttpContext.Session.SessionID));
                Response.Cookies["sessionKey"].Expires = DateTime.Now.AddHours(12);
                _sessionId = ctx.HttpContext.Session.SessionID;
            }

            DIYFELib.Tracking.InsertTracking(_sessionId,
                                            _ipAddress,
                                            ctx.HttpContext.Request.Url.PathAndQuery);

            ViewBag.PageModel = PageModel;
        }
开发者ID:sumdood31,项目名称:DIYFE,代码行数:35,代码来源:ApplicationController.cs


示例12: OnResultExecuting

 public void OnResultExecuting(ResultExecutingContext filterContext)
 {
     if (filterContext.Result is JsonResult)
     {
         (filterContext.Result as JsonResult).JsonRequestBehavior = JsonRequestBehavior.AllowGet;
     }
 }
开发者ID:phoenixwebgroup,项目名称:Accountability,代码行数:7,代码来源:SetJsonRequestBehaviorGlobally.cs


示例13: OnResultExecuting

        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            if (!filterContext.HttpContext.Request.IsHomePage()) return;

            var globalSettings = _seoSettingsManagerWork.Value.GetGlobalSettings();

            if (!String.IsNullOrEmpty(globalSettings.HomeTitle)) {
                _pageTitleBuilderWork.Value.OverrideTitle(Tokenize(globalSettings.HomeTitle));
            }

            var resourceManager = _resourceManagerWork.Value;

            if (!String.IsNullOrEmpty(globalSettings.HomeDescription)) {
                resourceManager.SetMeta(new MetaEntry {
                    Name = "description",
                    Content = Tokenize(globalSettings.HomeDescription)
                });
            }

            if (!String.IsNullOrEmpty(globalSettings.HomeKeywords)) {
                resourceManager.SetMeta(new MetaEntry {
                    Name = "keywords",
                    Content = Tokenize(globalSettings.HomeKeywords)
                });
            }
        }
开发者ID:CloudMetal,项目名称:CloudMetal-Pipeline-Deploy,代码行数:26,代码来源:HomePageFilter.cs


示例14: OnResultExecuting

        public override void OnResultExecuting(ResultExecutingContext filterContext)
        {
            HttpContextBase context = filterContext.HttpContext;

            User user = null;
            string fcAuthToken = null;

            if (filterContext.HttpContext.Session["currentUser"] != null)
            {
                user = (User)filterContext.HttpContext.Session["currentUser"];
            }

            if (context.Request.Cookies[ApplicationConfiguration.FriendConnectCookie] != null)
            {
                fcAuthToken = context.Request.Cookies[ApplicationConfiguration.FriendConnectCookie].Value;
            }

            if (user == null && fcAuthToken == null)
            {
                filterContext.HttpContext.Response.Redirect("/Login", true);
            }
            else if (user != null && fcAuthToken == null)
            {
                context.Session.Remove("currentUser");
                filterContext.HttpContext.Response.Redirect("/Logout", true);
            }
        }
开发者ID:pragmaticobjects,项目名称:ExploreFriendConnect,代码行数:27,代码来源:RequiresAuthenticationAttribute.cs


示例15: OnResultExecuting

        public void OnResultExecuting(ResultExecutingContext filterContext)
        {
            // Kirigami should only run on a full view rendering result
            var viewResult = filterContext.Result as ViewResult;
            if (viewResult == null)
                return;

            var workContext = _workContextAccessor.GetContext(filterContext);

            // Some standard checks
            if (workContext == null ||
                workContext.Layout == null ||
                workContext.CurrentSite == null ||
                AdminFilter.IsApplied(filterContext.RequestContext))
            {
                return;
            }

            // TODO: Build and add shape to zone.
            /*var zones = workContext.Layout.Zones;
            foreach (var widgetPart in widgetParts)
            {
                if (activeLayerIds.Contains(widgetPart.As<ICommonPart>().Container.ContentItem.Id))
                {
                    var widgetShape = _contentManager.BuildDisplay(widgetPart);
                    zones[widgetPart.Record.Zone].Add(widgetShape, widgetPart.Record.Position);
                }
            }*/

        }
开发者ID:rupertwhitlock,项目名称:IncreasinglyAbsorbing,代码行数:30,代码来源:ShapePastingFilter.cs


示例16: Ensure_All_Ancestor_ViewData_Is_Merged_Without_Data_Loss

        public void Ensure_All_Ancestor_ViewData_Is_Merged_Without_Data_Loss()
        {
            var http = new FakeHttpContextFactory("http://localhost");

            //setup an heirarchy
            var rootViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, ViewData = new ViewDataDictionary() };
            var parentViewCtx = new ViewContext { Controller = new MyController(), RequestContext = http.RequestContext, RouteData = new RouteData(), ViewData = new ViewDataDictionary() };
            parentViewCtx.RouteData.DataTokens.Add("ParentActionViewContext", rootViewCtx);
            var controllerCtx = new ControllerContext(http.RequestContext, new MyController()) { RouteData = new RouteData() };
            controllerCtx.RouteData.DataTokens.Add("ParentActionViewContext", parentViewCtx);

            //set up the view data with overlapping keys
            controllerCtx.Controller.ViewData["Test1"] = "Test1";
            controllerCtx.Controller.ViewData["Test2"] = "Test2";
            controllerCtx.Controller.ViewData["Test3"] = "Test3";
            parentViewCtx.ViewData["Test2"] = "Test4";
            parentViewCtx.ViewData["Test3"] = "Test5";
            parentViewCtx.ViewData["Test4"] = "Test6";
            rootViewCtx.ViewData["Test3"] = "Test7";
            rootViewCtx.ViewData["Test4"] = "Test8";
            rootViewCtx.ViewData["Test5"] = "Test9";

            var filter = new ResultExecutingContext(controllerCtx, new ContentResult()) { RouteData = controllerCtx.RouteData };
            var att = new MergeParentContextViewDataAttribute();

            Assert.IsTrue(filter.IsChildAction);
            att.OnResultExecuting(filter);

            Assert.AreEqual(5, controllerCtx.Controller.ViewData.Count);
            Assert.AreEqual("Test1", controllerCtx.Controller.ViewData["Test1"]);
            Assert.AreEqual("Test2", controllerCtx.Controller.ViewData["Test2"]);
            Assert.AreEqual("Test3", controllerCtx.Controller.ViewData["Test3"]);
            Assert.AreEqual("Test6", controllerCtx.Controller.ViewData["Test4"]);
            Assert.AreEqual("Test9", controllerCtx.Controller.ViewData["Test5"]);
        }
开发者ID:phaniarveti,项目名称:Experiments,代码行数:35,代码来源:MergeParentContextViewDataAttributeTests.cs


示例17: OnResultExecuting

        public void OnResultExecuting(ResultExecutingContext filterContext) {
            // should only run on a full view rendering result
            if (!(filterContext.Result is ViewResult)) {
                return;
            }

            WorkContext workContext = _workContextAccessor.GetContext(filterContext);

            const string menuName = "admin";
            if (!AdminFilter.IsApplied(filterContext.RequestContext)) {
                return;
            }

            IEnumerable<MenuItem> menuItems = _navigationManager.BuildMenu(menuName);

            // Set the currently selected path
            Stack<MenuItem> selectedPath = NavigationHelper.SetSelectedPath(menuItems, filterContext.RouteData);

            // Populate main nav
            dynamic menuShape = _shapeFactory.Menu().MenuName(menuName);
            NavigationHelper.PopulateMenu(_shapeFactory, menuShape, menuShape, menuItems);

            // Add any know image sets to the main nav
            IEnumerable<string> menuImageSets = _navigationManager.BuildImageSets(menuName);
            if (menuImageSets != null && menuImageSets.Any())
                menuShape.ImageSets(menuImageSets);

            workContext.Layout.Navigation.Add(menuShape);

            // Populate local nav
            dynamic localMenuShape = _shapeFactory.LocalMenu().MenuName(string.Format("local_{0}", menuName));
            NavigationHelper.PopulateLocalMenu(_shapeFactory, localMenuShape, localMenuShape, selectedPath);
            workContext.Layout.LocalNavigation.Add(localMenuShape);
        }
开发者ID:seifipour,项目名称:exams4doctors,代码行数:34,代码来源:MenuFilter.cs


示例18: OnResultExecuting

 // executes before controller
 public override void OnResultExecuting(ResultExecutingContext filterContext)
 {
     // start a transaction
     var t = new TransactionScope();
     HttpContext.Current.Items["transaction"] = t;
     base.OnResultExecuting(filterContext);
 }
开发者ID:elbandit,项目名称:PPPDDD,代码行数:8,代码来源:TransactionFilter.cs


示例19: Should_delegate_to_result_filter_executing

		public void Should_delegate_to_result_filter_executing()
		{
			var attribute = new FilterUsingAttribute(typeof(TestResultFilter));
			var context = new ResultExecutingContext();
			attribute.OnResultExecuting(context);
			context.Result.ShouldBe<EmptyResult>();
		}
开发者ID:somlea-george,项目名称:sutekishop,代码行数:7,代码来源:FilterUsingAttributeTester.cs


示例20: OnResultExecuting

 public void OnResultExecuting(ResultExecutingContext filterContext)
 {
     timer = Stopwatch.StartNew();
     filterContext.HttpContext.Response.Write(
     string.Format("<div>Result starte time: {0}</div>",
     System.DateTime.Now.ToShortTimeString()));
 }
开发者ID:jojozhuang,项目名称:Study,代码行数:7,代码来源:ProfileResultAttribute.cs



注:本文中的System.Web.Mvc.ResultExecutingContext类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Mvc.SelectList类代码示例发布时间:2022-05-26
下一篇:
C# Mvc.ResultExecutedContext类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap