Skip to content

Instantly share code, notes, and snippets.

@model Web.Models.ContentRecommender
@if (Model == null)
{
if (Sitecore.Context.PageMode.IsExperienceEditor)
{
<div>Datasource item not set</div>
}
return;
public ActionResult ContentRecommender()
{
var contactId = Tracker.Current.Contact.ContactId.ToString();
var model = HttpContext.Session[contactId] as ContentRecommender;
HttpContext.Session.Remove(contactId);
return this.View("~/path to my view/ContentRecommender.cshtml", model);
}
namespace MyNamespace.Web.Models
{
public class ContentRecommender
{
public Item ContentItem { get; set; }
public List<ContentDetail> ContentDetail { get; set; }
}
public class ContentDetail
namespace MyNamespace.Web.Rules
{
public class FilterByGoals<T> : Sitecore.Rules.Conditions.WhenCondition<T> where T : RuleContext
{
protected override bool Execute(T ruleContext)
{
var contentItems = Factory.GetDatabase("master").GetItem("/sitecore/content/Contents").GetChildren().ToList();
var contents = new List<ContentDetail>();
[Throttle(TimeUnit = TimeUnit.Minute, Count = 5)]
[Throttle(TimeUnit = TimeUnit.Day, Count = 20)]
[HttpPost]
public JsonResult LoginAccount(MyUserModel user)
{
// Your action method implementation
}
public enum TimeUnit
{
Minute = 60,
Hour = 3600,
Day = 86400
}
[AttributeUsage(AttributeTargets.Method, AllowMultiple = true)]
public class ThrottleAttribute : ActionFilterAttribute
{
[ServicesController]
[Throttle("Item name of throttle strategy")]
public class MyCustomController : ApiController
{
[Route("api/myapp/getiteminfo")]
return new[]
{
"The Key : " + Guid.NewGuid()
};
}
[ServicesController]
[RequiredApiKey]
public class MyCustomController : ApiController
[Throttle("Throttle Strategy Item Name Here")]
[Route("api/myapp/getiteminfo")]
public IEnumerable<string> GetData()
{
return new[]
{
"The Key : " + Guid.NewGuid()
[ServicesController]
[RequiredApiKey]
public class MyCustomController : ApiController
[Route("api/myapp/getiteminfo")]
public IEnumerable<string> GetItemInfo()
{
return new[]
{
"The Key : " + Guid.NewGuid()
};
@hishaamn
hishaamn / Patch.Sitecore.Throttle.config
Last active August 25, 2022 07:43
Activation of Sitecore Throttling
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<settings>
<setting name="Sitecore.Services.IsThrottleEnabled" value="true" />
</settings>
</sitecore>
</configuration>