public static string ReadFile(this IHostingEnvironmentAwareViewComponent vc, string file)
        {
            if (string.IsNullOrWhiteSpace(file))
            {
                return(null);
            }

            var path     = vc.GetContentFilePath(file);
            var fileInfo = vc.HostingEnvironment.ContentRootFileProvider.GetFileInfo(path);

            return(fileInfo.Exists ? GetFileContent(fileInfo) : null);
        }
 private static string GetContentFilePath(this IHostingEnvironmentAwareViewComponent vc, string file) =>
 Path.IsPathRooted(file)
         ? file
         : Path.Combine(Path.GetDirectoryName(vc.ViewContext.ExecutingFilePath), file);