If you want to upload "large" files e.g. <= 100MB, on any ASP .NET website, you must edit the web.config file.

There are many settings that you might want to update, when uploading large files e.g. session, request timeouts etc.

 

In this post I will only address the web.config attributes:

But the same steps can be used to update other elements / attributes in the web.config file.

 

Factory Configuration

In Outsystems, on every publish of a eSpace a new web.config file is produced. In order to update this new web.config file, we will have to use the Outsystems solution pack "Factory Configuration". Download the outsystems solution pack "Factory Configuration":http://www.outsystems.com/forge/component/25/Service+Center+Factory+Configuration/

(Service.Center.Factory.Configuration-8.0.0.osp = 325kb)

clip_image001

 

Click on 1-Click Publish

clip_image002

 

Open the page http://localhost/FactoryConfiguration in a browser.

clip_image003

Click on Shared Configurations

clip_image004

Click on Create New Shared Configuration

 

Paste in the XSLT from below:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<!-- 
Description
This xslt is used to add uploading of large files capabilities to a outsystems eSpace on IIS.
- It will upsert the attribute system.web/httpRuntime/@maxRequestLength (<=IIS6).
- It will upsert the attribute system.webServer/security/requestFiltering/requestLimits/@maxAllowedContentLength (>=IIS7).
-->
<!-- Just copy all other xml parts, that don't have a specific template match. -->
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="configuration">
<!-- Create an "configuration" element in the output document. -->
<configuration>
<!-- Copy child elements to output document. -->
<xsl:apply-templates select="@*|node()"/>
<!-- If the element "system.web" does not exist, create it in the output document. -->
<xsl:if test="count(system.web) = 0">
<system.web>
<httpRuntime maxRequestLength="102400"  />
</system.web>
</xsl:if>   
<!-- If the element "system.webServer" does not exist, create it in the output document. -->
<xsl:if test="count(system.webServer) = 0">
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</security>
</system.webServer>
</xsl:if>
</configuration>
</xsl:template>
<!-- If the element "system.web/httpRuntime" does not exist, add it. -->
<xsl:template match="system.web[not(httpRuntime)]">
<system.web>
<xsl:apply-templates select="@*|node()"/>
<httpRuntime maxRequestLength="102400"  />
</system.web>
</xsl:template>
<!-- If the attribute "system.web/httpRuntime/@maxRequestLength" does not exist, add it. -->
<xsl:template match="system.web/httpRuntime[not(@maxRequestLength)]">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:attribute name="maxRequestLength">
<xsl:value-of select="'102400'"/>
</xsl:attribute>
</xsl:copy>
</xsl:template>
<!-- If the attribute "system.web/httpRuntime/@maxRequestLength" exists update it. -->
<xsl:template match="system.web/httpRuntime/@maxRequestLength">
<xsl:attribute name="maxRequestLength">
<xsl:value-of select="'102400'"/>
</xsl:attribute>
</xsl:template>
<!-- If the element "system.webServer/security" does not exist, add it. -->
<xsl:template match="system.webServer[not(security)]">
<system.webServer>
<xsl:apply-templates select="@*|node()"/>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</security>
</system.webServer>
</xsl:template>
<!-- If the element "system.webServer/security/requestFiltering" does not exist, add it. -->
<xsl:template match="system.webServer/security[not(requestFiltering)]">
<security>
<xsl:apply-templates select="@*|node()"/>
<requestFiltering>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</security>
</xsl:template>
<!-- If the element "system.webServer/security/requestFiltering/requestLimits" does not exist, add it. -->
<xsl:template match="system.webServer/security/requestFiltering[not(requestLimits)]">
<requestFiltering>
<xsl:apply-templates select="@*|node()"/>
<requestLimits maxAllowedContentLength="104857600"/>
</requestFiltering>
</xsl:template>
<!-- If the attribute "system.webServer/security/requestFiltering/requestLimits/@maxAllowedContentLength" does not exist, add it. -->
<xsl:template match="system.webServer/security/requestFiltering/requestLimits[not(@maxAllowedContentLength)]">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
<xsl:attribute name="maxAllowedContentLength">
<xsl:value-of select="'104857600'"/>
</xsl:attribute>
</xsl:copy>
</xsl:template>
<!-- If the attribute "system.webServer/security/requestFiltering/requestLimits/@maxAllowedContentLength" exists update it. -->
<xsl:template match="system.webServer/security/requestFiltering/requestLimits/@maxAllowedContentLength">
<xsl:attribute name="maxAllowedContentLength">
<xsl:value-of select="'104857600'"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>

Now as you can see, I ‘m not a XSLT goeroe, so someone will tell me, this is a lot of XSLT code for something that simple, please do Smile.

 

 

Click on Create

clip_image005

Now the shared configuration is created, we must associate it to the eSpaces in which we want to use it.

 

Go to the eSpaces tab

clip_image006

 

Select "Add_upload_large_files_capabilities"

clip_image007

Click on Associate

 

 

Now on every publish of an eSpace the web.config of that eSpace will be altered to support uploading of large (<= 100MB) files. After deploying your eSpace, you can check the web.config on the filesystem of the server, to verify the changes were correctly executed. In my case, the web.config was found at: C:\Program Files\OutSystems\Platform Server\running\RliTest.0494247501

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.