SitefinityViewEngine doesnt check if View exists
I have observed that the SitefinityViewEngine.FindsView method does not check if a view file exists when returning a result.
It formats the view path using the prescribed MVC folder (e.g. ~/Mvc/Views/Browse/Index.cshtml) and returns a view result but does not check if that file exists.
This is in contrast to SitefinityViewEngenine.FindPartialView that does check if the file exists.
When using multiple view engines it means that the SitefinityViewEngine can prevent other view engines that can FindView from returning a correct answer. Each IViewEngine is called in order, first time using cache, second time bypassing cache. SiteFinityViewEngine.FindView also ignores the useCache parameter, so it will return a view result on the first pass preventing other ViewEngines from returning a view result when use cache is false.
Can the SitefinityViewEngine be updated to check if a file exists for FindView or enable/disable FindView file checking.
Hello Gary,
Yes, this is correct, I have verified in our source and indeed there is a check in FindPartialView method:
public
ViewEngineResult FindPartialView(ControllerContext controllerContext,
string
partialViewName,
bool
useCache)
if
(controllerContext ==
null
)
throw
new
ArgumentNullException(
"controllerContext"
);
var viewPath =
this
.GetPartialViewPath(controllerContext, partialViewName,
null
);
if
(
string
.IsNullOrEmpty(viewPath) || !
this
.FileExists(viewPath))
...
Thanks Vassil.