ASP.NET框架错误

Max*_*ich 16 c# asp.net deployment debugging

进入您的iis机器级别设置并添加

<deployment retail="true" /> 
Run Code Online (Sandbox Code Playgroud)

http://msdn.microsoft.com/en-us/library/ms228298.aspx中所述

创建一个新的Web项目,添加一个标签,然后添加以下代码.

protected void Page_Load(object sender, EventArgs e)
{
    Label1.Text = HttpContext.Current.IsDebuggingEnabled.ToString();
}

//Result: true 
Run Code Online (Sandbox Code Playgroud)

我错过了什么?

更新:我更新了64位和32位版本的机器配置的值.服务器正在运行IIS7.5.重启没有帮助.

更新2:

使用Reflector逐步执行框架的V4,我得到以下代码.

public bool IsDebuggingEnabled
{
    get
    {
        try
        {
            return CompilationUtil.IsDebuggingEnabled(this);
        }
        catch
        {
            return false;
        }
    }
}

internal static bool IsDebuggingEnabled(HttpContext context)
{
    return MTConfigUtil.GetCompilationConfig(context).Debug;
}

//Here is where I lose whats going on... Either way, if what Yaur said is correct then
//I believe that value is not only useless but dangerously misleading. 
internal static CompilationSection GetCompilationConfig(HttpContext context)
{
    if (!UseMTConfig)
    {
        return RuntimeConfig.GetConfig(context).Compilation;
    }
    return GetConfig<CompilationSection>(context);
}
Run Code Online (Sandbox Code Playgroud)

无论哪种方式.我可以确认的是,功能似乎不起作用.

PS:@Yaur - 是的我已尝试更改该值,并且我很清楚使用此方法的替代方法,但重点是该方法应该简化部署.

mat*_*ieu 8

根据:http://weblogs.asp.net/scottgu/archive/2006/04/11/442448.aspx,它应该强制:

<system.web>
  <compilation debug="false">
</system.web>
Run Code Online (Sandbox Code Playgroud)

你重启了服务器吗?你编辑了哪个machine.config?


Yau*_*aur 7

在反射器中查看HttpContext,所有这个方法都是加载编译部分中找到的值.所以设定为mathieu建议你,你应该是金.
另外(如果你关心的话)如果在mono下运行会抛出异常.

从System.Web 的2.0版本:

它叫

CompilationUtil.IsDebuggingEnabled(this);

哪个叫

RuntimeConfig.GetConfig(context).Compilation.Debug;

Compilation.Get返回

(CompilationSection) this.GetSection("system.web/compilation", typeof(CompilationSection), ResultsIndex.Compilation);

4.0版本有点不同......基于我可以告诉它看起来"额外的东西"是多目标支持.因此,如果你的目标.net 4并且设置<compilation debug="false">不起作用,请尝试按照此处的示例使用

<system.web>
    <compilation debug="false" targetFramework="4.0">
</compilation>
Run Code Online (Sandbox Code Playgroud)

代替