ASP.NET front-end .aspx page (hiding code when deployed).
I’m trying to simply have a button for us developers that auto-fills this gigantic form, the only thing I’ve been able to find is this:
<script>
$(function () {
<% If (Context.IsDebuggingEnabled) Then %>
$('#fillForm').show().on('click', function () {
// nothing special here, loops through items and fills them in
});
<% End If %>
// other normal JS code here
});
</script>
The problem is when the project is pushed into the live test environment, they still see the button! It starts out as: display:none;, and somehow this code is being hit even on when deployed!
SOLUTION:: Thanks to @Icarus
Test environment web.config also has
<compilation debug="true">
For it to work only within our development environment I had to do:
<% If (System.Configuration.ConfigurationManager.AppSettings("Environment").ToUpper() = " DEVELOPMENT") Then %>
// stuff here
<% End if %>
That means your
Web.configin production still hasdebug=truein the compilation Section. You should always set the flag tofalsewhen deploying to Production. There’s a performance hit, and it may expose more details about exceptions than one would want a user to be able to see.