public ActionResult Index() { var model = new RobotsTxtViewModel(); var allHostsList = GetHostsSelectListItems(); model.SiteList = allHostsList; if (allHostsList.Count > 0) model.RobotsContent = RobotsService.GetRobotsContent(allHostsList.First().Value); return View(model); }
public ActionResult Edit(RobotsTxtViewModel model) { RobotsService.SaveRobotsContent(model.RobotsContent, model.SiteId); if (model.SiteId.EndsWith("*")) { string siteId = model.SiteId.Split(">".ToCharArray())[0].Trim(); const string confirmationMessage = "Sucessfully saved robots.txt content. All requests for Site ID '{0}' that do not have an explicit host name mapping will serve this content"; model.SuccessMessage = string.Format(confirmationMessage, siteId); } else { string hostLink = string.Format("<a href=\"http://{0}/robots.txt\" target=\"_blank\">http://{0}/robots.txt</a>", model.SiteId.Split(">".ToCharArray())[1].Trim()); string confirmationMessage = "Sucessfully saved robots.txt content. All requests to {0} will serve this content"; model.SuccessMessage = string.Format(confirmationMessage, hostLink); } model.KeyActionPath = "../"; model.SiteList = GetHostsSelectListItems(); return View("Index", model); }