public async Task <ModuleAction> GetAction_DownloadNewsSiteMapAsync() { if (!IsAuthorized("NewsSiteMap")) { return(null); } NewsSiteMap sm = new NewsSiteMap(); string filename = sm.GetNewsSiteMapFileName(); if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename)) { return(null); } return(new ModuleAction(this) { Url = Utility.UrlFor(typeof(CategoriesBrowseModuleController), nameof(CategoriesBrowseModuleController.DownloadNewsSiteMap)), NeedsModuleContext = true, CookieAsDoneSignal = true, Image = await CustomIconAsync("Download.png"), LinkText = this.__ResStr("downloadLink", "Download News Site Map"), MenuText = this.__ResStr("downloadMenu", "Download News Site Map"), Tooltip = this.__ResStr("downloadTT", "Download the news site map file"), Legend = this.__ResStr("downloadLegend", "Downloads the news site map file"), Style = ModuleAction.ActionStyleEnum.Normal, Category = ModuleAction.ActionCategoryEnum.Read, Mode = ModuleAction.ActionModeEnum.Any, Location = ModuleAction.ActionLocationEnum.ModuleLinks, }); }
public async Task <ActionResult> DownloadNewsSiteMap(long cookieToReturn) { NewsSiteMap sm = new NewsSiteMap(); string filename = sm.GetNewsSiteMapFileName(); if (!await FileSystem.FileSystemProvider.FileExistsAsync(filename)) { throw new Error(this.__ResStr("sitemapNotFound", "News site map not found - File '{0}' cannot be located", filename)); } #if MVC6 Response.Headers.Remove("Cookie"); Response.Cookies.Append(Basics.CookieDone, cookieToReturn.ToString(), new Microsoft.AspNetCore.Http.CookieOptions { HttpOnly = false, Path = "/" }); #else HttpCookie cookie = new HttpCookie(Basics.CookieDone, cookieToReturn.ToString()); Response.Cookies.Remove(Basics.CookieDone); Response.SetCookie(cookie); #endif string contentType = "application/octet-stream"; #if MVC6 return(new PhysicalFileResult(filename, contentType) { FileDownloadName = Path.GetFileName(filename) }); #else FilePathResult result = new FilePathResult(filename, contentType); result.FileDownloadName = Path.GetFileName(filename); return(result); #endif }