James Skemp
James Skemp

Reputation: 8551

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 'debug 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?

Upvotes: 2

Views: 4745

Answers (1)

Darin Dimitrov
Darin Dimitrov

Reputation: 1038710

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.

Upvotes: 2

Related Questions