我注意到 Asp.net MVC 3 在 .cshtml 文件之前搜索 .aspx 文件。我可以更改此搜索顺序吗?以及如何做到这一点?
背景信息
调试时出现以下异常:
The view 'Reset' or its master was not found. The following locations were searched:
~/Views/Demo/Reset.aspx
~/Views/Demo/Reset.ascx
~/Views/Shared/Reset.aspx
~/Views/Shared/Reset.ascx
~/Views/Demo/Reset.cshtml
~/Views/Demo/Reset.vbhtml
~/Views/Shared/Reset.cshtml
~/Views/Shared/Reset.vbhtml
我由此得出结论,首先搜索旧的 .aspx View 。
由于我将网站转换为 MVC3,并将所有 View 转换为 Razor,因此我希望首先搜索 .cshtml 文件。我认为这对于性能来说会更好。
最佳答案
是的。 Change the order of the existing view engines. .
但在非调试配置中,文件位置被缓存,因此它仅对第一次查找有帮助。我不会担心。
关于asp.net - 我可以更改 ASP.Net MVC 3 应用程序物理 View 的搜索顺序吗,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4198566/