本文整理汇总了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);
}
示例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;
}
示例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;
}