public IActionResult AbsoluteContent() { return(new ContentResult() { Content = Url.AbsoluteContent("UrlHelper/AbsoluteContent") }); }
public async Task <ActionResult> Upload() { var returnList = new List <MosaicoFileInfo>(); for (int i = 0; i < Request.Files.Count; i++) { var file = Request.Files[i]; if (file.ContentLength > 0) { string fileName = file.FileName; string filePath = Server.MapPath(Path.Combine("~/Media/Uploads", fileName)); string thumbPath = Server.MapPath(Path.Combine("~/Media/Thumbs", fileName)); file.SaveAs(filePath); var image = System.Drawing.Image.FromFile(filePath); var thumbnail = ImageHelper.Resize(image, 120, 90); thumbnail.Save(thumbPath); returnList.Add(new MosaicoFileInfo { name = fileName, size = file.ContentLength, type = MimeMapping.GetMimeMapping(fileName), url = Url.AbsoluteContent(string.Concat("/Media/Uploads/", fileName)), thumbnailUrl = Url.AbsoluteContent(string.Concat("/Media/Thumbs/", fileName)), deleteUrl = string.Concat("/mosaico/img-delete/", fileName), deleteType = "DELETE" }); } } return(Json(new { files = returnList })); }
public IActionResult Get() { var appRoot = Url.AbsoluteContent("~/"); var remoteServiceRoot = Url.AbsoluteContent("~/"); var startUpData = new StartUpData( appName: _appConfigHelper.AppName, appRoot: appRoot, inDebug: false, remoteServiceRoot: remoteServiceRoot, version: _appConfigHelper.Version); return(Ok(startUpData)); }
private Uri ConvertToAbsoluteUri(string returnUrl) { NullGuard.NotNullOrWhiteSpace(returnUrl, nameof(returnUrl)); if (Uri.TryCreate(returnUrl, UriKind.RelativeOrAbsolute, out Uri returnUri) == false) { return(null); } if (returnUri.IsAbsoluteUri) { return(returnUri); } return(ConvertToAbsoluteUri(Url.AbsoluteContent(returnUri.OriginalString))); }
public ActionResult GetUploads() { string path = Server.MapPath("~/Media/Uploads"); var files = (new DirectoryInfo(path)).GetFiles().Select(x => new MosaicoFileInfo { name = x.Name, size = x.Length, type = MimeMapping.GetMimeMapping(x.Name), url = Url.AbsoluteContent(string.Concat("/Media/Uploads/", x.Name)), thumbnailUrl = Url.AbsoluteContent(string.Concat("/Media/Thumbs/", x.Name)), deleteUrl = string.Concat("/mosaico/img-delete/", x.Name), deleteType = "DELETE" }); return(Json(new { files = files }, JsonRequestBehavior.AllowGet)); }
public IActionResult GetUploads() { string path = Path.Combine(hostingEnvironment.WebRootPath, "Media/Uploads"); var files = (new DirectoryInfo(path)).GetFiles().Select(x => new MosaicoFileInfo { Name = x.Name, Size = x.Length, Type = MimeMapping.GetMimeMapping(x.Name), Url = Url.AbsoluteContent(string.Concat("/Media/Uploads/", x.Name)), ThumbnailUrl = Url.AbsoluteContent(string.Concat("/Media/Thumbs/", x.Name)), DeleteUrl = string.Concat("/mosaico/img-delete/", x.Name), DeleteType = "DELETE" }); return(Ok(new { files = files })); }
public ActionResult SitemapXml() { var urls = new List <SitemapUrl>(); foreach (var provider in providers) { urls.AddRange(provider.GetSitemapUrls(Url).ToList()); } // Home page urls.Insert(0, new SitemapUrl("Home", Url.AbsoluteContent("~/")) { Priority = 1 }); return(new XmlSitemapResult(urls)); }
public ActionResult SitemapHtml() { var urls = new List <SitemapUrl>(); foreach (var provider in providers) { urls.AddRange(provider.GetSitemapUrls(Url).ToList()); } // Home page urls.Insert(0, new SitemapUrl("Home", Url.AbsoluteContent("~/")) { Priority = 1 }); var sb = new StringBuilder(); using (var textWriter = new StringWriter(sb)) { using (var writer = new HtmlTextWriter(textWriter)) { writer.AddAttribute(HtmlTextWriterAttribute.Class, "sitemap"); writer.RenderBeginTag(HtmlTextWriterTag.Div); writer.AddAttribute(HtmlTextWriterAttribute.Id, "primaryNav"); writer.RenderBeginTag(HtmlTextWriterTag.Ul); foreach (var url in urls) { RenderSitemapUrl(writer, url); } writer.RenderEndTag(); // ul writer.RenderEndTag(); // div writer.Flush(); textWriter.Flush(); ViewBag.Title = "Sitemap"; return(new ControlContentResult(sb.ToString())); } } }
public async Task <IActionResult> Upload() { var files = Request.Form.Files; var returnList = new List <MosaicoFileInfo>(); foreach (var file in files) { if (file.Length > 0) { string filePath = Path.Combine(hostingEnvironment.WebRootPath, "Media/Uploads", file.FileName); string thumbPath = Path.Combine(hostingEnvironment.WebRootPath, "Media/Thumbs", file.FileName); using (var stream = new FileStream(filePath, FileMode.Create)) { await file.CopyToAsync(stream); } using (var stream = new MemoryStream()) { await file.CopyToAsync(stream); var image = System.Drawing.Image.FromStream(stream); var thumbnail = ImageHelper.Resize(image, 120, 90); thumbnail.Save(thumbPath); } returnList.Add(new MosaicoFileInfo { Name = file.FileName, Size = file.Length, Type = MimeMapping.GetMimeMapping(file.FileName), Url = Url.AbsoluteContent(string.Concat("/Media/Uploads/", file.FileName)), ThumbnailUrl = Url.AbsoluteContent(string.Concat("/Media/Thumbs/", file.FileName)), DeleteUrl = string.Concat("/mosaico/img-delete/", file.FileName), DeleteType = "DELETE" }); } } return(Ok(new { files = returnList })); }