Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET framework bug

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.

like image 391
Maxim Gershkovich Avatar asked May 20 '11 08:05

Maxim Gershkovich


People also ask

What is a .NET Framework error?

Error causes This error typically indicates one of the following conditions: A . NET Framework installation on your system has become corrupted. The version of . NET Framework needed by your application cannot be detected.

Why is .NET Framework not installing?

Go to Control Panel > Programs > Turn Windows features on or off, verify if . NET Framework 3.5 checkbox is selected and then proceed with the software installation. If the error persits, we will have to force the installation with the Windows command prompt (CMD).

Is .NET Framework outdated?

NET is dead as a future framework for web applications and software. Microsoft won't be building for it and they won't support it. But software that already runs on . NET and is no longer being updated will still run on it.


2 Answers

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 ?

like image 113
mathieu Avatar answered Sep 27 '22 19:09

mathieu


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

like image 42
Yaur Avatar answered Sep 27 '22 21:09

Yaur