This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @model Web.Models.ContentRecommender | |
| @if (Model == null) | |
| { | |
| if (Sitecore.Context.PageMode.IsExperienceEditor) | |
| { | |
| <div>Datasource item not set</div> | |
| } | |
| return; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| namespace MyNamespace.Web.Models | |
| { | |
| public class ContentRecommender | |
| { | |
| public Item ContentItem { get; set; } | |
| public List<ContentDetail> ContentDetail { get; set; } | |
| } | |
| public class ContentDetail |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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>(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [Throttle(TimeUnit = TimeUnit.Minute, Count = 5)] | |
| [Throttle(TimeUnit = TimeUnit.Day, Count = 20)] | |
| [HttpPost] | |
| public JsonResult LoginAccount(MyUserModel user) | |
| { | |
| // Your action method implementation | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public enum TimeUnit | |
| { | |
| Minute = 60, | |
| Hour = 3600, | |
| Day = 86400 | |
| } | |
| [AttributeUsage(AttributeTargets.Method, AllowMultiple = true)] | |
| public class ThrottleAttribute : ActionFilterAttribute | |
| { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ServicesController] | |
| [Throttle("Item name of throttle strategy")] | |
| public class MyCustomController : ApiController | |
| { | |
| [Route("api/myapp/getiteminfo")] | |
| return new[] | |
| { | |
| "The Key : " + Guid.NewGuid() | |
| }; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| [ServicesController] | |
| [RequiredApiKey] | |
| public class MyCustomController : ApiController | |
| [Route("api/myapp/getiteminfo")] | |
| public IEnumerable<string> GetItemInfo() | |
| { | |
| return new[] | |
| { | |
| "The Key : " + Guid.NewGuid() | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <configuration xmlns:patch="http://www.sitecore.net/xmlconfig/"> | |
| <sitecore> | |
| <settings> | |
| <setting name="Sitecore.Services.IsThrottleEnabled" value="true" /> | |
| </settings> | |
| </sitecore> | |
| </configuration> |