/// <summary> /// Serves single-page app's page requests. /// </summary> /// <param name="paras">The entire relative URL.</param> public IActionResult Index(string paras) { var pi = pageProvider.GetPage(paras, true); if (pi == null) { pi = pageProvider.GetPage("404", true); } // If it's the results page, we cheat: retrieve score and fill title right here // Needed so Facebook shows my actual number when sharing string title = pi.Title; if (pi.RelNorm.StartsWith("/ergebnis/")) { string uid = pi.RelNorm.Replace("/ergebnis/", ""); uid = uid.Substring(0, 10); int score = resultRepo.LoadScore(uid); title = title.Replace("*", score.ToString()); } PageResult pr = new PageResult { NoIndex = pi.NoIndex, Title = title, Description = pi.Description, Keywords = pi.Keywords, Html = pi.Html }; IndexModel model = new IndexModel(pr, gaCode); return(View("/Index.cshtml", model)); }
/// <summary> /// Serves single-page app's dynamic content requests for in-page navigation. /// </summary> /// <param name="rel">Relative URL of content.</param> public IActionResult GetPage([FromForm] string rel) { var pi = pageProvider.GetPage(rel, false); if (pi == null) { pi = pageProvider.GetPage("404", false); } PageResult res = new PageResult { NoIndex = pi.NoIndex, Title = pi.Title, Description = pi.Description, Keywords = pi.Keywords, Html = pi.Html }; return(new ObjectResult(res)); }