Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why my MVC views are compiled with PDB?

Now this is interesting!

I just noticed that exceptions in my MVC Views have line-numbers in the stack trace! Which means - my views are compiled with PDB.

I looked at the "Temporary ASP.NET Files" folder on my server - and yes, there are PDB files for every view.

I have <compilation debug="false"/> in my web.config.

Why is this happening and how do I disable that? This is the production server, so I would like to disable the pdb-generation.

I checked my "web.config", "Views/web.config", "machine.config", default "web.config" in windir%\Microsoft.NET\Framework64\[version]\config\ - I think I haven't found any suspicious compiler options there... Where do I look?

Or am I just wasting my time and this is the default option that cannot be changed?

PS. More info, just in case: this is an MVC 4 app, the Views are written in Razor.

like image 511
Alex from Jitbit Avatar asked Jun 24 '15 19:06

Alex from Jitbit


1 Answers

Found it!!

Seems like this is the default setting for Razor - it is always compiled with DEBUG option and you can't change it - but I think I found the solution.

Adding this to your machine.config seem to fix the issue:

<configuration>
    <system.web>
        <deployment retail="true"/>
    <system.web>
</configuration>

At least I don't see any more .pdb's in my "Temp ASP.NET Files".

More info about this flag on ScottGu's blog: http://weblogs.asp.net/scottgu/Don_1920_t-run-production-ASP.NET-Applications-with-debug_3D001D20_true_1D20_-enabled

like image 161
Alex from Jitbit Avatar answered Sep 22 '22 13:09

Alex from Jitbit