diff --git a/src/Umbraco.Core/Services/FileService.cs b/src/Umbraco.Core/Services/FileService.cs index f81110c338..fc1bbf34d2 100644 --- a/src/Umbraco.Core/Services/FileService.cs +++ b/src/Umbraco.Core/Services/FileService.cs @@ -1066,19 +1066,6 @@ namespace Umbraco.Core.Services : Attempt.Fail(); } - internal Attempt TryGetViewPath(string fileName) - { - if (fileName.EndsWith(".cshtml") == false) - { - fileName += ".cshtml"; - } - - string viewPath = IOHelper.MapPath(SystemDirectories.MvcViews + "/" + fileName); - return System.IO.File.Exists(viewPath) - ? Attempt.Succeed(viewPath) - : Attempt.Fail(); - } - private IPartialViewRepository GetPartialViewRepository(PartialViewType partialViewType, IUnitOfWork uow) { switch (partialViewType) @@ -1115,16 +1102,20 @@ namespace Umbraco.Core.Services if (filename.IsNullOrWhiteSpace()) throw new ArgumentNullException(nameof(filename)); - Attempt viewAttempt = TryGetViewPath(filename); - if (viewAttempt.Success == false) + if (filename.EndsWith(".cshtml") == false) { - return null; + filename = $"{filename}.cshtml"; } using (var uow = UowProvider.GetUnitOfWork()) { var repository = RepositoryFactory.CreateTemplateRepository(uow); - var stream = repository.GetFileContentStream(viewAttempt.Result); + var stream = repository.GetFileContentStream(filename); + + if (stream == null) + { + return null; + } using (var reader = new StreamReader(stream, Encoding.UTF8, true)) {