ASP.NET 框架错误

发布于 2024-11-09 07:43:40 字数 1471 浏览 0 评论 0原文

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

<deployment retail="true" /> 

正如 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 

我缺少什么?

更新:我更新了 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);
}

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

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

Go into your iis machine level settings and add

<deployment retail="true" /> 

As specified in http://msdn.microsoft.com/en-us/library/ms228298.aspx

Create a new web project, add a label and then the following code.

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

//Result: true 

What am I missing?

Update: I updated the value on the 64 and 32 bit versions of the machine config. The server is running IIS7.5. Reboot didn't help.

Update 2:

Stepping through V4 of the framework using Reflector I get the following code.

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);
}

Either way. What I can confirm is that the functionality does not seem to work.

PS: @Yaur - Yes I have tried changing the value and I am well aware of the alternatives to using this method but the point is that this method is supposed to simplify deployment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

零崎曲识 2024-11-16 07:43:41

查看反射器中的 HttpContext,此方法所做的就是加载在编译部分中找到的值。因此,按照马蒂厄的建议进行设置,你应该是金色的。
另外(如果你关心的话)如果在单声道下运行它会抛出异常。

从 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 并且设置 不起作用,请尝试按照示例 此处

<system.web>
    <compilation debug="false" targetFramework="4.0">
</compilation>

使用

Looking at HttpContext in reflector all this method does is to load the value found in the compilation section. So set that as mathieu suggested and you you should be golden.
Also (if you care) it will throw an exception if running under mono.

from the 2.0 version of System.Web:

it calls

CompilationUtil.IsDebuggingEnabled(this);

which calls

RuntimeConfig.GetConfig(context).Compilation.Debug;

Compilation.Get returns

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

the 4.0 version is a bit different... based on what I can tell it looks the "extra stuff" is multitargeting support. So if you are targeting .net 4 and setting <compilation debug="false"> didn't work try following the example here and use

<system.web>
    <compilation debug="false" targetFramework="4.0">
</compilation>

instead

半透明的墙 2024-11-16 07:43:40

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

<system.web>
  <compilation debug="false">
</system.web>

您重新启动服务器了吗?
您编辑了哪个 machine.config ?

According to : http://weblogs.asp.net/scottgu/archive/2006/04/11/442448.aspx, it should force :

<system.web>
  <compilation debug="false">
</system.web>

Have you rebooted your server ?
Which machine.config did you edit ?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文