Пример #1
0
        // GET: Home
        public ActionResult Index()
        { // If the request is not from a bot => control goes to Durandal app
            if (Request.QueryString["_escaped_fragment_"] == null)
            {
                return(View());
            }

            // If the request contains the _escaped_fragment_, then we return an HTML Snapshot to the bot
            try
            {
                StateManager.RegisterPageVisit(Core.Enums.AreaType.Home);

                var result = _snapshotRepository.Fetch(Request.Url.AbsolutePath);
                if (result != null)
                {
                    return(Content(result.Html));
                }
                else
                {
                    result = _snapshotRepository.Fetch("/");
                    if (result != null)
                    {
                        return(Content(result.Html));
                    }
                }

                return(View());
            }
            catch (Exception ex)
            {
                return(View());
            }
        }
Пример #2
0
        public HttpResponseMessage Get()
        {
            try
            {
                var snapshots = _repository.Fetch().Select(s => new Snapshot(s)).ToList();

                if (snapshots.Count > 0)
                {
                    return(Request.CreateResponse(HttpStatusCode.OK, snapshots.ToDictionary(k => k.Url, v => v.Date)));
                }

                return(Request.CreateResponse(HttpStatusCode.NoContent));
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }