public IActionResult SourceCode() { string Platform = HttpContext.Request.Query["platform"]; Dictionary <string, Dictionary <string, object> > data = DownloadViewModel.GetDownloadInfo(); if (!data.ContainsKey(Platform)) { return(ErrorView()); } string fileName = (data[Platform].ContainsKey("file")) ? data[Platform]["file"].ToString() : null; if (string.IsNullOrEmpty(fileName)) { return(ErrorView()); } // 计算下载次数。 DownloadViewModel.CalcDownloadCount(Platform); string FullPath = System.IO.Path.Combine(string.Format(@"{0}\Downloads", HostingEnvironment.WebRootPath), fileName); if (!(System.IO.File.Exists(FullPath))) { return(ErrorView()); } FileStreamResult FileView = new FileStreamResult(System.IO.File.Open(FullPath, FileMode.Open, FileAccess.Read), "application/octet-stream"); FileView.FileDownloadName = fileName; return(FileView); }