Turn CustomErrors off and on quickly for production and development

bdigital

New Member
I develop a lot of ASP.NET web forms. During testing, I have customErrors off, then I have a ResponseRedirect custom error for when I move the form into production.I'm wondering if I can simplify my development by just changing a setting value to accomplish this.What I would like is to just change my Properties.Settings.Default.TestMode value from developer to production and have this turn on the customError.So I was thinking my Global.asax.cs code could look like:\[code\]protected void Application_Error(object sender, EventArgs e) { if (Properties.Settings.Default.TestMode == "production") { Server.ClearError(); Response.Redirect("errorpage.htm"); } else { // Not sure what it would do here. Nothing? }}\[/code\]But then I'm not sure what would go in my Web.config file.CustomErrors is shown below.\[code\]<!--<customErrors mode="Off" />--><customErrors mode="On" defaultRedirect="ErrorPage.htm" redirectMode="ResponseRedirect"/>\[/code\]Right now I just comment out/in what I need to to make the change. I feel like I do this all the time and it would be great to just have the TestMode setting that I've created do all the work.
 
Back
Top