当前位置: 首页>>代码示例>>C#>>正文


C# PublishedContentRequest.SetRedirect方法代码示例

本文整理汇总了C#中Umbraco.Web.Routing.PublishedContentRequest.SetRedirect方法的典型用法代码示例。如果您正苦于以下问题:C# PublishedContentRequest.SetRedirect方法的具体用法?C# PublishedContentRequest.SetRedirect怎么用?C# PublishedContentRequest.SetRedirect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Umbraco.Web.Routing.PublishedContentRequest的用法示例。


在下文中一共展示了PublishedContentRequest.SetRedirect方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TryFindContent

        public override bool TryFindContent(PublishedContentRequest contentRequest)
        {
            // Mobile logout
            if (contentRequest.Uri.AbsolutePath.Contains("for-members/login/logout=1"))
            {
                contentRequest.SetRedirect("/umbraco/Surface/MembersSurface/Logout");
                return true;
            }

            // 180 day Password Expiration Policy
            var member = Membership.GetUser();
            if (member != null && (DateTime.Now - member.LastPasswordChangedDate).TotalDays >= 180
                && !contentRequest.Uri.AbsoluteUri.Contains("your-account/change-password"))
            {
                contentRequest.SetRedirect("/your-account/change-password/");
                return true;
            }
            return base.TryFindContent(contentRequest);
        }
开发者ID:HRINY,项目名称:HRI-Umbraco,代码行数:19,代码来源:HriContentFinder.cs

示例2: TryRedirect

        private static bool TryRedirect(PublishedContentRequest contentRequest, bool includeQuery)
        {
            bool redirect = false;
            string path = string.Format("{0}{1}{2}", contentRequest.Uri.Authority
                                                   , contentRequest.Uri.AbsolutePath
                                                   , includeQuery ? contentRequest.Uri.Query : String.Empty
                                       );

            RedirectInfo redirectInfo;

            if (RedirectFromTo.TryGetValue(path, out redirectInfo) && !string.IsNullOrWhiteSpace(redirectInfo.To))
            {
                contentRequest.SetRedirect(redirectInfo.To, redirectInfo.StatusCode);
                redirect = true;
            }

            return redirect;
        }
开发者ID:codevos,项目名称:UmbracoContentFinders,代码行数:18,代码来源:SeoRedirectContentFinder.cs

示例3: TryFindContent

		public bool TryFindContent(PublishedContentRequest contentRequest)
		{
			var stores = StoreHelper.GetAllStores();

			if (!stores.Any())
			{
				return false;
			}

			var uwebshopRequest = UwebshopRequest.Current;
			var content = uwebshopRequest.Product ?? uwebshopRequest.Category ?? uwebshopRequest.PaymentProvider ?? // in case ResolveUwebshopEntityUrl was already called from the module
						  IO.Container.Resolve<IUrlRewritingService>().ResolveUwebshopEntityUrl().Entity;

			if (content is PaymentProvider)
			{
				var paymentProvider = content as PaymentProvider;

				Log.Instance.LogDebug("UmbracoDefaultAfterRequestInit paymentProvider: " + paymentProvider.Name);

				new PaymentRequestHandler().HandleuWebshopPaymentRequest(paymentProvider);

				var publishedContent = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetById(paymentProvider.Id);
				if (publishedContent == null) return false;
				contentRequest.PublishedContent = publishedContent;

				SetRequestCulture(contentRequest);
				return true;
			}

			if (content is Category)
			{
				var categoryFromUrl = content as Category;

				if (categoryFromUrl.Disabled) return false;

				if (Access.HasAccess(categoryFromUrl.Id, categoryFromUrl.Path, Membership.GetUser()))
				{
					var doc = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetById(content.Id);
					if (doc != null)
					{
						contentRequest.PublishedContent = doc;
						var altTemplate = HttpContext.Current.Request["altTemplate"];
						contentRequest.TrySetTemplate(altTemplate);

						SetRequestCulture(contentRequest);
						return true;
					}
				}
				else
				{
					if (HttpContext.Current.User.Identity.IsAuthenticated)
					{
						contentRequest.SetRedirect(library.NiceUrl(Access.GetErrorPage(categoryFromUrl.Path)));
					}
					contentRequest.SetRedirect(library.NiceUrl(Access.GetLoginPage(categoryFromUrl.Path)));
					return true;
				}
			}

			else if (content is Product)
			{
				var productFromUrl = content as Product;
				if (productFromUrl.Disabled) return false;

				if (Access.HasAccess(productFromUrl.Id, productFromUrl.Path, Membership.GetUser()))
				{
					var doc = contentRequest.RoutingContext.UmbracoContext.ContentCache.GetById(content.Id);
					if (doc != null)
					{
						contentRequest.PublishedContent = doc;
						var altTemplate = HttpContext.Current.Request["altTemplate"];
						contentRequest.TrySetTemplate(altTemplate);

						SetRequestCulture(contentRequest);
						return true;
					}
				}
				else
				{
					if (HttpContext.Current.User.Identity.IsAuthenticated)
					{
						contentRequest.SetRedirect(library.NiceUrl(Access.GetErrorPage(productFromUrl.Path)));
					}
					contentRequest.SetRedirect(library.NiceUrl(Access.GetLoginPage(productFromUrl.Path)));
					return true;
				}
			}
			return false;
		}
开发者ID:Chuhukon,项目名称:uWebshop-Releases,代码行数:89,代码来源:CatalogContentFinder.cs


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