Exemplo n.º 1
0
        public async Task<ViewResult> SiteChecker(string url)
        {
			if (!string.IsNullOrWhiteSpace(url))
			{
				var stopwatch = new Stopwatch();
				stopwatch.Start();


				var siteUri = new Uri(url);
				var crawler = new Crawler(siteUri);
				var links = await crawler.CheckPageLinks();
                siteLinks = links;

				stopwatch.Stop();
				var time = stopwatch.Elapsed;
				ViewBag.StopWatch = string.Format("{0}m {1}s", time.Minutes, time.Seconds);
				ViewBag.PageCount = links.Select(x => x.PageUrl.AbsolutePath).Distinct().Count();
				ViewBag.LinkCount = links.Count;

				//links = links.Where(x => x.StatusCode >= 400 && x.StatusCode < 500).ToList();

				return this.View(links);
			}
			else
			{
				return this.View();
			}
        }