显示视图的当前搜索路径 [英] Show current search paths for a view

查看:87
本文介绍了显示视图的当前搜索路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对视图进行故障排除,以及为什么它找不到编辑器模板.显然,它与我们在CustomRazorViewEngine中配置搜索路径的方式有关,但是仅查看它,它就应该起作用.相反,它将呈现默认的MVC编辑器模板,因为它找不到自定义模板.

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?

推荐答案

这可能不是最好的方法,但是将其添加到控制器中对我来说是有效的:

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

这篇关于显示视图的当前搜索路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆