开发者

Can a debug=true directive be added to an ASP.NET MVC view?

I'm sure this has been asked before, but after numerous searches I can't seem to determine whether it's possible to put a single page in 'deb开发者_StackOverflow中文版ug mode' in ASP.NET MVC.

In ASP.NET Web Forms, you can do one of the following (stolen from the yellow screen of death):

1) Add a "Debug=true" directive at the top of the file that generated the error. Example:

<%@ Page Language="C#" Debug="true" %>

2) Add the following section to the configuration file of your application:

<configuration>
    <system.web>
        <compilation debug="true"/>
    </system.web>
</configuration>

In this particular instance I'd like to be able to do the former, since I'd like more information on just one page, where there's an issue in the view.

Do I have to go the Web.config route instead, with ASP.NET MVC?


Yes in ASP.NET MVC you should use the corresponding section in web.config to determine the debug mode. Just make sure you don't ship with debug="true" in production as ASP.NET MVC does some optimizations like caching view locations based on this property. So as it name suggests use only in debug mode. You might also want to take a look at ELMAH when you ship in production.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜