I have this small helper code that works fine locally, but on Umbraco Cloud it returns nothing.
public HtmlString RenderSVGInline(MediaWithCrops svg) {
string webRootPath = _webHostEnvironment.WebRootPath;
string url = svg.Url();
string path = $"{webRootPath}{url}";
string toReturn = string.Empty;
try {
if (System.IO.File.Exists(path)) {
toReturn = System.IO.File.ReadAllText(path);
if (!string.IsNullOrWhiteSpace(toReturn) && toReturn.IndexOf("<svg") > 0) {
toReturn = toReturn.Substring(toReturn.IndexOf("<svg"));
}
}
} catch (Exception ex) {
return new HtmlString("<span style=\"background:#f998;color:#000;\">" + ex.ToString() + "</span>");
}
return new HtmlString(toReturn);
}
So I guess it has something to do with Cloud using Azure Blob Storage.
How to I make this work both locally and on Umbraco Cloud ?