📄 Documentation: IrbyImaging/web.config
📑 Table of Contents
- Overview & Purpose
- File Structure
- Key Configuration Sections
- Configuration Settings Deep Dive
- Impact on Application Behavior
- Usage & Deployment
- Best Practices & Recommendations
- Troubleshooting & Error Handling
- Sample Scenarios & Usage Examples
- Conclusion
🧐 Overview & Purpose
The web.config file is an ASP.NET configuration file used by IIS (Internet Information Services) to control various settings for the IrbyImaging web application. It allows you to:
- Configure HTTP runtime limits
- Enable the .NET garbage collector to handle very large objects
- Fine-tune request filtering and security headers
Intended Use: This configuration is optimized for scenarios that involve uploading and processing very large images (up to ~2 GB) without hitting default ASP.NET thresholds or IIS request limits.
📁 File Structure
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<!-- ~ 2GB -->
<httpRuntime maxUrlLength="2147483647"
maxRequestLength="2147483647" />
</system.web>
<runtime>
<gcAllowVeryLargeObjects enabled="true" />
</runtime>
<system.webServer>
<security>
<requestFiltering removeServerHeader="true">
<requestLimits maxAllowedContentLength="334217728" />
</requestFiltering>
</security>
</system.webServer>
</configuration>
🔑 Key Configuration Sections
1. system.web
- Controls ASP.NET runtime behavior, particularly HTTP runtime limits.
2. runtime
- Configures .NET CLR (Common Language Runtime) settings such as the garbage collector.
3. system.webServer
- Defines IIS-specific settings (security, request filtering, headers).
🛠 Configuration Settings Deep Dive
| Section | Element/Attribute | Default Value | Overridden Value | Purpose |
|---|---|---|---|---|
| system.web | <httpRuntime> |
maxRequestLength=4096 | maxRequestLength=2147483647 | Maximum request size (in KB) that ASP.NET will accept. |
| runtime | <gcAllowVeryLargeObjects> |
disabled (false) |
enabled (true) |
Allows arrays/objects >2 GB on 64-bit systems. |
| system.webServer | <requestFiltering> |
Server header present | removeServerHeader=true |
Hides IIS version header for security. |
| system.webServer | <requestFiltering><requestLimits> |
maxAllowedContentLength=30000000 (≈28.6MB) | 334217728 (≈319 MB) | Limits HTTP content length in bytes. |
httpRuntime
<httpRuntime
maxUrlLength="2147483647"
maxRequestLength="2147483647" />
- maxUrlLength: Maximum characters allowed in the URL (approx. 2 GB).
- maxRequestLength: Maximum request size in kilobytes (~2 GB).
gcAllowVeryLargeObjects
<gcAllowVeryLargeObjects enabled="true" />
- When enabled, the .NET GC can allocate arrays or objects larger than 2 GB on 64-bit platforms.
- Use Case: Processing extremely large image buffers or byte arrays.
requestFiltering & requestLimits
<requestFiltering removeServerHeader="true">
<requestLimits maxAllowedContentLength="334217728" />
</requestFiltering>
- removeServerHeader (
true): Strips theServerHTTP header to hide IIS version info (security best practice). - maxAllowedContentLength: Sets maximum HTTP content length in bytes (≈319 MB).
Note: IIS’s limit is enforced independently of ASP.NET’s
httpRuntime. Both must be tuned for large uploads.
🌐 Impact on Application Behavior
- Large File Uploads
- Allows uploads of very large images without
413 Request Entity Too Largeor404.13errors.
- Allows uploads of very large images without
- Memory Management
- GC can handle huge in-memory byte arrays, reducing fragmentation.
- Security Enhancements
- Hiding server header reduces fingerprinting risk.
🚀 Usage & Deployment
- Place
web.configat the root of theIrbyImagingweb application directory. - Ensure IIS is running in 64-bit mode to benefit from
gcAllowVeryLargeObjects. - Recycle App Pool after changes to apply new settings.
- Test uploads with images of increasing size.
💡 Best Practices & Recommendations
- Always backup existing
web.configbefore modifications. - Gradually ramp up
maxAllowedContentLengthto monitor memory/CPU footprint. - Enable logging to detect and diagnose large request failures.
- Use HTTPS to protect large payloads in transit.
- Combine with chunked uploads or streaming when dealing with multi-GB files.
⚠️ Troubleshooting & Error Handling
| Symptom | Possible Cause | Solution |
|---|---|---|
| HTTP 404.13 / 413 Request Too Large | maxAllowedContentLength or maxRequestLength too low |
Increase limits; recycle app pool. |
| OutOfMemoryException on large array allocation | GC not allowing >2 GB on 32-bit or setting disabled | Enable gcAllowVeryLargeObjects; use 64-bit. |
| Unexpected errors after config update | Malformed XML; invalid attribute values | Validate XML; correct typos. |
📂 Sample Scenarios & Usage Examples
Example 1: Uploading a 300 MB Image
- Client sends a
POSTwith a 300 MB JPEG. - IIS checks
maxAllowedContentLength(319 MB) → OK. - ASP.NET checks
maxRequestLength(~2 GB) → OK. - Application reads request stream into a
byte[](>2 GB support enabled). - Image processing proceeds in memory.
Example 2: Hardening for Production
<system.webServer>
<security>
<!-- Hide IIS fingerprint -->
<requestFiltering removeServerHeader="true">
<requestLimits maxAllowedContentLength="104857600" /> <!-- 100 MB -->
</requestFiltering>
</security>
</system.webServer>
- Reduced upload limit to 100 MB for stricter control.
- Monitor and adjust according to business needs.
🏁 Conclusion
The IrbyImaging/web.config is tuned to handle very large image uploads (up to ~2 GB in ASP.NET and ~319 MB in IIS by default) while improving security by removing server headers. Proper configuration of these settings enables robust, high-volume imaging scenarios without hitting default platform limits.
Feel free to adjust the values to meet your specific throughput, memory, and security requirements! 🚀
End of Documentation