Show current search paths for a view

烂漫一生 提交于 2019-12-24 13:33:47

问题


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:


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();


来源:https://stackoverflow.com/questions/13867259/show-current-search-paths-for-a-view

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!