📄 Documentation: IrbyImaging/web.config


📑 Table of Contents

  1. Overview & Purpose
  2. File Structure
  3. Key Configuration Sections
    1. system.web
    2. runtime
    3. system.webServer
  4. Configuration Settings Deep Dive
  5. Impact on Application Behavior
  6. Usage & Deployment
  7. Best Practices & Recommendations
  8. Troubleshooting & Error Handling
  9. Sample Scenarios & Usage Examples
  10. 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 the Server HTTP 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

  1. Large File Uploads
    • Allows uploads of very large images without 413 Request Entity Too Large or 404.13 errors.
  2. Memory Management
    • GC can handle huge in-memory byte arrays, reducing fragmentation.
  3. Security Enhancements
    • Hiding server header reduces fingerprinting risk.

🚀 Usage & Deployment

  1. Place web.config at the root of the IrbyImaging web application directory.
  2. Ensure IIS is running in 64-bit mode to benefit from gcAllowVeryLargeObjects.
  3. Recycle App Pool after changes to apply new settings.
  4. Test uploads with images of increasing size.

💡 Best Practices & Recommendations

  • Always backup existing web.config before modifications.
  • Gradually ramp up maxAllowedContentLength to 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

  1. Client sends a POST with a 300 MB JPEG.
  2. IIS checks maxAllowedContentLength (319 MB) → OK.
  3. ASP.NET checks maxRequestLength (~2 GB) → OK.
  4. Application reads request stream into a byte[] (>2 GB support enabled).
  5. 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