asp.net – system.web.compilation.debug与system.codedom.comp
当我将ASP.NET Web应用程序部署到生产环境时,我使用配置转换从< compilation>中删除debug =“true”.但是,就在今天我注意到web.config中的另一个部分如下所示:
<system.codedom> <compilers> <compiler compilerOptions="/define:Debug=True" /> </compilers> </system.codedom> 这是什么?事实是,那就是打败了从< compilation>中删除它的目的吗?如果我删除上面显示的属性会怎样? 解决方法
从MSDN C# Compiler Options起
因此,当您定义Debug = True时,您只能将此情况设为true: #if DEBUG == true // Compile what is inside here ! #endif / define:Debug = True不会添加任何其他调试信息,除非您使用上述代码手动包含它们. 测试页面 我使用以下代码进行测试,看看发生了什么. txtDebug.Text = HttpContext.Current.IsDebuggingEnabled.ToString(); #if DEBUG txtDebug.Text += "<br>defined Debug is on"; #endif #if DEBUG == true txtDebug.Text += "<br>defined Debug = true is on"; #endif 结果1 现在,如果debug =“false”并且使用compilerOptions =“/ define:Debug = True”,结果是
结果2 如果debug =“true”和compilerOptions =“/ define:Debug = True”结果是
结果3 现在我再做一次测试,我在web.config上添加了这一行 <compiler language="c#;cs;csharp" extension=".cs" compilerOptions="/define:Debug=True /D:DEBUG,TESTFLAG" type="Microsoft.CSharp.CSharpCodeProvider,System,Version=4.0.0.0,Culture=neutral,PublicKeyToken=b77a5c561934e089" warningLevel="4" /> 结果是debug = false
MSDN 看看MSDN for the /define (Preprocessor Definition)我看那个宣言 /define:Debug=True 只适用于这种代码的情况 #if DEBUG == true txtDebug.Text += "<br>defined Debug = true is on"; #endif (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
- asp.net – 数据库加密或应用程序级加密?
- asp.net-web-api – 为什么Microsoft.Owin.Host.SystemWeb无
- asp.net – 如果Ninject尚未绑定,如何在Ninject中绑定?
- asp.net – 如何通过在MasterPage上单击按钮来处理usercont
- 在ASP.NET中托管时找不到端点
- asp.net-mvc – ASP.NET MVC IIS7.5:将网站从W7移动到Wind
- asp.net-core – 如何检索当前响应体长度?
- asp.net-mvc – ASP.NET MVC表单身份验证和未经身份验证的控
- ASP.NET – 如何从数据库有效地创建动态用户特定菜单
- asp.net-mvc – 如果MVC3中的值超出范围,如何添加消息?