Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><strong>This answer is community wiki so as not to generate any reputation, as it's effectively a reworking of DOK's answer. If you like it, please upvote DOK's answer.</strong></p> <p>@Dok, if you want to edit your answer to incorporate any of this, please do, and I'll gladly delete this answer. :)</p> <p>DOK, as mentioned in my comments to your answer (and possibly some help for your own solution), you might want to do the following:</p> <pre><code>#if DEBUG //As mentioned by DOK in the comments. If you set debug to false when building for deployment, the code in here will not be compiled. protected void Page_PreInit(object sender, EventArgs e) { bool inDevMode = false; inDevMode = bool.Parse(ConfigurationManager.AppSettings["InDevMode"]); //Or you could use TryParse if(inDevMode) { // Fake authentication so I don't have to create a damn Login page just for this. System.Web.Security.FormsIdentity id = new FormsIdentity(new FormsAuthenticationTicket("dok", false, 30)); string[] roles = { "a" }; HttpContext.Current.User = new System.Security.Principal.GenericPrincipal(id, roles); } } #endif </code></pre> <p>To further ensure that you do not accidentally deploy with this active, then you would have your app settings in seperate config files (as well as your debug section). If you use <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=0AA30AE8-C73B-4BDD-BB1B-FE697256C459&amp;displaylang=en" rel="nofollow noreferrer">Web Deployment</a> projects, then you can put your dev config settings in one file, and your live config files in another (this is usually dev.config and live.config!).</p> <p>eg, in your web.config:</p> <pre><code>&lt;appSettings file="dev.config"/&gt; </code></pre> <p>In your dev.config:</p> <pre><code>&lt;appSettings&gt; &lt;add key="InDevMode" value="true" /&gt; &lt;/appSettings&gt; </code></pre> <p>In your live.config:</p> <pre><code>&lt;appSettings&gt; &lt;add key="InDevMode" value="false" /&gt; &lt;/appSettings&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload