I have created a custom error page for 404.13, which is what occurs when a user attempts to upload a file larger than a size set in the config files under maxAllowedContentLength. I want my .aspx file to say something like:

Maximum allowed file size=________KB

Trouble is, I can't figure out how to get the value from a server config file onto my .aspx page. Any ideas?

Hi,
Verify the configuration/system.webServer/security/requestFiltering/requestLimits@maxAllowedContentLength setting in the applicationhost.config or web.config file

Try this:

%windir%\system32\inetsrv\appcmd set config -section:requestFiltering -requestLim
its.maxAllowedContentLength:1000000

or if you only want to set it for your app:

%windir%\system32\inetsrv\appcmd set config "Default Web Site/<your app>" -section:requestFiltering -requestLimits.maxAllowedContentLength:1000000

Hope this helps

Now in order to get this to work u have to modify the overrideModeDefault from "Deny" to "Allow" like so:

<section name="requestFiltering" overrideModeDefault="Allow" />

:)

Why not just move it over as a constant? I don't think the value set in your configuration is the final word in determining upload size however. IIS can inherit settings from machine-wide policies, override parent directories, etc. So I think there is probably an API call you should be looking for but I can't seem to find it either.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.