每当我的Razor视图(.cshtml)中出现错误时,我都会看到一个黄色屏幕,指出
生成此内容的源代码 未处理的异常只能显示 在调试模式下编译时。启用 这个,请按照以下其中一个 步骤,然后请求URL:
然后说要么在视图中设置<@ Page Debug="true">
,要么在web.config中设置<compilation debug="true">
。
我检查了我的web.config并且<compilation debug="true">
已经设置好了。为了耗尽其他选项,我尝试将其添加到视图文件夹中的所有web.config
文件中,但没有更改。
我还检查过项目编译为Debug
而不是Release
。有关为什么没有显示错误被抛出的源代码的任何想法?
编辑:我的应用程序已从ASP.NET MVC 2更新为MVC 3。
答案 0 :(得分:0)
当信任级别设置为中等时,显然不会显示源错误。
我在完成中等信任测试后忘记从web.config文件中删除<trust level="medium" />
。
答案 1 :(得分:-1)
1) source errors does not appear if you do not insert customErrors mode="Off" and compilation debug="true" in your web.config 2) when you're in medium trust you can use mvc3 provided you : cast your return view(xxx) to return view((Object)xxx) or, in vb: return view(xxx) to return DirectCast(view(xxx), Object) and Return View(model) to Return View((Object)model) or to Return View(DirectCast(model, Object)) and you do not use @ViewBag