KB's

How to use the real extensions for the items in the Images and Documents module

Problem:

The default item hyperlinks generated by the Images and Documents module end up with .sflb or .sflb.ashx.
Starting from Sitefinity 3.6, there is an option for you to use the real file extensions (for example .jpg,.doc).

Solution:

1. Open your web.config file and remove the comment tags on the lines below:
before:
<modules> 
…  
      <!--<remove name="LibraryModule"/>--> 
…  
      <!--<add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries"/>--> 
…  
</modules> 
…  
<httpModules> 
…  
      <!--<add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries"/>--> 
…  
</httpModules> 
 

after:
<modules> 
…  
      <remove name="LibraryModule"/>  
…  
      <add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries"/>  
…  
</modules> 
…  
<httpModules> 
…  
      <add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries"/>  
…  
</httpModules> 
 

2. Change the extension in the urlRewriteFormat for the Libraries provider:
before:
<cmsEngine defaultProvider="Generic_Content">  
      <providers>  …  
<add name="Libraries"   
urlRewriteFormat="~/{Provider}/{LibraryName}/[Name].sflb.ashx"   
...   
      </providers> 
 
 

after:
<cmsEngine defaultProvider="Generic_Content">  
      <providers> 
<add name="Libraries"   
urlRewriteFormat="~/{Provider}/{LibraryName}/[Name]{Extension}"   
…  
       </providers> 
 

3. Set the extensions you want to use in your web.config:
<libraries defaultGenericProvider="Libraries">  …  
<extensionMapping defaultExtension=".sflb.ashx">  
    <add key=".jpg"/>  
    <add key=".pdf"/>  
    <add key=".doc"/>  
    <add key=".xls"/>  
</extensionMapping> 
</libraries>

Note: The defaultExtension attribute's value must be set to the old extension from the urlRewriteFormat attribute (see step 2).

4. If your site is running in a Classic Pipeline mode, please make sure to map the extensions you want to use in the IIS. Instructions for adding a handler mapping in the IIS can be found in Sitefinity User Manual, section Configuring IIS.