NoWar
NoWar

Reputation: 37633

.NET doesn't read properly web.config?

I have

   <system.web>
        <httpRuntime maxRequestLength="500000000"  />
    </system.web>

But when I read web.config via

 Configuration config = WebConfigurationManager.OpenWebConfiguration(configPath);

            HttpRuntimeSection section =
              (HttpRuntimeSection)config.GetSection("system.web/httpRuntime"); 

I see 4096 value for maxRequestLength!!

How it could be?? Thanks for any clue!

P.S. It is ASP .NET MVC3 Razor project

Upvotes: 0

Views: 349

Answers (2)

Diego
Diego

Reputation: 18359

My guess is that 500,000,000 Kb is above the maximum value for the maxRequestLength property, so it's being assigned its default value (4,096). The documentation does not say what's the maximum value that maxRequestLength can take, but my guess is 20,97,151 Kb because that's roughly equal to 2^31 bytes, the maximum value that int can store.

Upvotes: 1

Dai
Dai

Reputation: 155145

There are a number of things to consider:

  • Is your <system.web> element a direct child of the <configuration> element?
  • Is your web.config file in the root of your IIS Application Scope root?
  • Is the <httpRuntime> element locked in the "root" .config file so values can't be overridden by other config files?

If you're using IIS then I recommend using the Configuration editor to investigate configuration precedence.

Upvotes: 1

Related Questions