當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。