Show current search paths for a view

2019-07-27 14:33发布

I'm trying to troubleshoot a view and why it can't find the editor templates. Obviously it has to do with how we've configured the search paths in the CustomRazorViewEngine, but just looking at it, it should be working. Instead, it's rendering the default MVC editor templates, because it can't find the custom ones.

How can I display the list of search paths for a view, or trigger an error so that it shows me the search paths it's looking for?

1条回答
戒情不戒烟
2楼-- · 2019-07-27 14:53

This may not be the best way, but adding this to the controller worked for me:

var searchedLocations = ViewEngines.Engines.[0]
    .FindPartialView(this.ControllerContext, "MyModel", false)
    .SearchedLocations
    .ToArray();
查看更多
登录 后发表回答