+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / urlRewrite for Libraries in Web.Config

urlRewrite for Libraries in Web.Config

14 posts, 0 answered
  1. Joel Kinzel
    Joel Kinzel avatar
    35 posts
    Registered:
    16 Jul 2009
    12 Nov 2010
    Link to this post

    Hi All,

    I found this page: http://www.sitefinity.com/devnet/kb/sitefinity-3-x/how-to-use-the-real-extensions-for-the-items-in-the-images-and-documents-module.aspx

    And attempted to implement the solution to no avail. I have followed the directions step-by-step and there is nothing really customized about the installation of SiteFinity (in is a pretty basic site actually). 

    But that may or may not matter because there is really another issue that is more "pressing" for me. In the Web.Config file there is this line (449 in my web.config): 

    1.<add name="Libraries" urlRewriteFormat="~//{LibraryName}/[Name]{Extension}" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="-" visible="False" defaultMetaField="Name" applicationName="/Libraries" allowVersioning="False" allowLocalization="False" localizationProviderName="" allowWorkflow="False" securityProviderName="" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Libraries.Data.DefaultProvider, Telerik.Libraries.Data" tagEditorTemplate="~/Sitefinity/Admin/ControlTemplates/Libraries/BatchTagsEditor.ascx"/>

    First as we know the "{Extension}" part is not working, but aside from that the [Name] pulls in the full file name used in the Documents and Images module. My question is what other values are valid to put there? And where would I find these? I would like to have the name that is displayed on the page, and the URL be completely separate. 

    For example: If I have a document named "Some really long title would be here" and the file name is "long-title.pdf", currently the URL would be this:  mysite.com/libraryname/Some-really-long-title-would-be-here.sflb.ashx. What I would like the URL to be would be something like "long-title.pdf". 

    How would I go about doing this? And is this doable using only the web.config file? 

    Thanks in advance and sorry for the rambling nature of the post. 

  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    13 Nov 2010
    Link to this post
    Hello Joel,

    1. You have two slashes added to the format - urlRewriteFormat="~//{LibraryName}/[Name]{Extension}". Please remove one of the slashes.

    2. To use real extension the only parameter that you can pass to the configuration is "{Extension}"

    If you do not want to work with real extensions you can use  "{ID}", "{GUID}", "{Provider}" keys in the urlRewriteFormat. All keys in squared brackets should be a metakeys of the Libraries provider.

    You can create an additional metakey ( User Manual , page 214 ,Adding Custom Fields)  where you type the short url of your item and then use it in the urlRewriteFormat.

    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Joel Kinzel
    Joel Kinzel avatar
    35 posts
    Registered:
    16 Jul 2009
    15 Nov 2010
    Link to this post

    Hi Ivan,

    Thanks for the response. I got the extension part of my original post working and now I am working through adding a custom field to the Images and Documents module. 

    I downloaded the PDF version of the documentation and there seems to be some things missing. First off, the links to other parts of the document are not working. They are blue and underlined but contain no active links to other parts of the document (using Adobe Reader 9.4.0). But that aside I am still having some difficulty getting through the instructions. 

    The documentation points to page 240 (more specifically 242 is where I am looking) for adding a field to the Images and Documents module (which is what I am using). There are a couple of very confusing sets early on in the instructions. On page 243 (step 3) it says "Add this to the XML file" but does not say which XML file? I looked in the ~/Sitefinity/Admin/ControlTemplates/Libraries/ directory but did not find any XML files. I assume it was not talking about the web.config file since it lists a root level element (which XML can only have 1 of). 

    Then in step 4 on page 243 it says "Unzip that download" but again never mentions which download (I am assuming there is some sort of download link missing)? 

    Thanks again for all your help! 

    Joel

  4. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    15 Nov 2010
    Link to this post
    Hello Joel,

    I believe that you should use the external templates package.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  5. Joel Kinzel
    Joel Kinzel avatar
    35 posts
    Registered:
    16 Jul 2009
    17 Nov 2010
    Link to this post

    Ivan,

    Thanks for all of your help thus far, I really do appreciate everything. 

    I seem to be having trouble with using the real extension. When I make the changes to the web.config file and then attempt to download the file from the live site I get a "File Not Found" error. The odd part is that I swear it was working before. Is there a permission that needs to be set somewhere either on the server or in the database to allow the real extension to be used? (note: switching it back to the original configuration works perfect). 

    Joel

  6. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    17 Nov 2010
    Link to this post
    Hello Joel,

    Not found error could be thrown if you do not have handler mappings in IIS for the real extensions you are going to us.

    Greetings,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Joel Kinzel
    Joel Kinzel avatar
    35 posts
    Registered:
    16 Jul 2009
    22 Nov 2010
    Link to this post

    Ivan -

    I do not believe it is the IIS configuration that is the issue. The only reason I say that is because the same site is able to properly serve .pdf files. If I go to   http://www.mysite.com/File/myFile.pdf it works, but anything that is stored in the Images and Documents library (and consequently in the database) is not being served correctly. Just for a double check I am going to paste the relevant sections of my web.config file so that you can review them:

    1.<httpModules>
    2.  <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    3.  <add name="Cms" type="Telerik.Cms.Web.CmsHttpModule, Telerik.Cms"/>
    4.  <!-- Http Module for extension mappings in Library module.-->
    5.  <add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries"/>
    6.  <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI"/>
    7.</httpModules>

    01.<modules>
    02.  <remove name="ScriptModule"/>
    03.  <remove name="Cms"/>
    04.  <remove name="LibraryModule"/>
    05.  <remove name="RadUploadModule"/>
    06.  <add name="ScriptModule" preCondition="managedHandler" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
    07.  <add name="Cms" type="Telerik.Cms.Web.CmsHttpModule, Telerik.Cms"/>
    08.  <!-- Http Module for extension mappings in Library module.-->
    09.  <add name="LibraryModule" type="Telerik.Libraries.LibraryHttpModule, Telerik.Libraries"/>
    10.  <add name="RadUploadModule" preCondition="managedHandler" type="Telerik.Web.UI.RadUploadHttpModule, Telerik.Web.UI"/>
    11.</modules>

    1.<libraries defaultGenericProvider="Libraries">
    2.  <extensionMapping defaultExtension=".sflb.ashx">
    3.<add key=".jpg"/>
    4.<add key=".pdf"/>
    5.<add key=".csv"/>
    6.<add key=".xls"/>
    7.  </extensionMapping>
    8.</libraries>

    I've tried to spot any errors, but do not see any. Hopefully this turns out to be something easy. I'm not sure if it matters but in any case we are using an Oracle db. 

  8. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    22 Nov 2010
    Link to this post
    Hi Joel,

    Do you have handler mappings for jpg, pdf , csv, xls as the KB suggests? What happens if you run the website through Visual Studio web server instead of IIS?

    Regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  9. Joel Kinzel
    Joel Kinzel avatar
    35 posts
    Registered:
    16 Jul 2009
    01 Dec 2010
    Link to this post

    Hi Ivan,

    Sure enough this was the problem. Apparently our server administrators just were not clear on exactly what I meant...anyways, all cleared up now! 

    Joel 

  10. Joel Kinzel
    Joel Kinzel avatar
    35 posts
    Registered:
    16 Jul 2009
    08 Dec 2010
    Link to this post

    Ivan,

    I now have the ShortURL field showing up in the administrator's view and it appears to be saved correctly. I followed the guide exactly and added the metaKey information.

    I replaced the [Name] in the UrlRewrite with [ShortURL]. The line now reads:

    1.<add name="Libraries" urlRewriteFormat="~/{LibraryName}/[ShortURL]{Extension}" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Name" applicationName="/Libraries" allowVersioning="False" allowLocalization="False" localizationProviderName="" allowWorkflow="False" securityProviderName="" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Libraries.Data.DefaultProvider, Telerik.Libraries.Data" tagEditorTemplate="~/Sitefinity/Admin/ControlTemplates/Libraries/BatchTagsEditor.ascx"/>

    However when I click on a document on the site itself the URL is incorrect it simply says "http://www.mysite.com/Library/.pdf" and links to the first document rather than the document it is supposed to link to. 

    Did I miss a step somewhere? 

    Joel

  11. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    13 Dec 2010
    Link to this post
    Hi Joel,

    I checked the url format and I was not able to replicate an issue with it. Could you try to upload a new image and check the url? Make sure that you have following properties of your metakey

    visible="True" searchable="True" sortable="True"

    Also make sure that you have added your metakey in <libraryInfo> section


    <libraryInfo>
    <add name="Image" title="Image Library" defaultExtenstions=".png, .jpg, .jpeg, .gif" metaKeys="Description, Author, AlternateText, Extension, Name, Height, Width, Size, Category, ShortURL"></add>


    Kind regards,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  12. Joel Kinzel
    Joel Kinzel avatar
    35 posts
    Registered:
    16 Jul 2009
    14 Dec 2010
    Link to this post

    Ivan,

    I am attempting to do this with the documents and images modules. Right now I'm actually trying to do this with a document (as I will only be using the "documents" part of the module). 

    Here is what I have:

    1.<metaFields>
    2.<add key="Libraries.ShortURL" valueType="ShortText" visible="True" searchable="True" sortable="True" defaultValue="" />
    3.</metaFields>

    1.<libraryInfo>
    2.<add name="Document" title="Document Library" defaultExtenstions=".doc, .docx, .rtf, .txt, .pdf, .ppt, .pps, .pptx, .html, .xls, .xlsx" metaKeys="Author, Description, Extension, Name, Size, Category, ShortURL"></add>
    3.</libraryInfo>

    and of course:

    1.<add name="Libraries" urlRewriteFormat="~/{LibraryName}/[ShortURL]{Extension}" urlDateTimeFormat="yy-MM-dd" urlWhitespaceChar="_" visible="False" defaultMetaField="Name" applicationName="/Libraries" allowVersioning="False" allowLocalization="False" localizationProviderName="" allowWorkflow="False" securityProviderName="" versioningProviderName="" connectionStringName="GenericContentConnection" type="Telerik.Libraries.Data.DefaultProvider, Telerik.Libraries.Data" tagEditorTemplate="~/Sitefinity/Admin/ControlTemplates/Libraries/BatchTagsEditor.ascx"/>

    Is there something special that needs to be done for documents? Or specifically the documents and images module? 

  13. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    09 Dec 2016
    16 Dec 2010
    Link to this post
    Hello Joel,


    From what you are saying it looks like that the metakey you use is not persisted

    Please check whether it is added to the edit template as shown below
    <sfGCn:ContentMetaFields ID="itemMetaFields" runat="server">
                       <ItemTemplate>
                           <h3>
                               <asp:Literal ID="Literal11" runat="server" Text="<%$Resources:ItemEdit_Details %>"></asp:Literal></h3>
                           <fieldset class="set">
                               <ol class="setIn">
                                   <li>
                                       <asp:Label ID="Label7" AssociatedControlID="Author" runat="server" Text="<%$Resources:ItemEdit_Author %>"></asp:Label>
                                       <asp:TextBox runat="server" ID="Author"></asp:TextBox>
                                   </li>
                                   <li>
                                       <asp:Label ID="Label5" runat="server" AssociatedControlID="Description" Text="<%$Resources:ItemEdit_DocumentDescription %>"></asp:Label>
                                       <asp:TextBox runat="server" ID="Description" TextMode="MultiLine"></asp:TextBox>
                                   </li>
                                    <li>
                                       <asp:Label ID="Label11" runat="server" AssociatedControlID="ShortURL" Text="ShortURL"></asp:Label>
                                       <asp:TextBox runat="server" ID="ShortURL" MaxLength="255"></asp:TextBox>
                                       
                                   </li>
                               </ol>
                           </fieldset>
                            <div class="bottom">
                               <div>
                                   <!-- -->
                               </div>
                           </div>
                           <h3>
                               <asp:Literal ID="Literal20" runat="server" Text="<%$Resources:ItemEdit_Category %>"></asp:Literal></h3>
                           <fieldset class="set">
                               <ol class="setIn">
                                   <li class="catSel clearfix">
                                       <asp:Label ID="Label8" AssociatedControlID="Category" runat="server">
                                           <asp:Literal ID="Literal1" runat="server" Text="<%$Resources:ItemEdit_Category %>"></asp:Literal>
                                       <em id="Em1" runat="server"></em></asp:Label>
                                       <sf:ContentCategoriesField ID="Category" runat="server" />
                                   </li>
                                    
                               </ol>
                           </fieldset>
                           <div class="bottom">
                               <div>
                                   <!-- -->
                               </div>
                           </div>
                           <h3>
                               <asp:Literal ID="Literal3" runat="server" Text="<%$Resources:ItemEdit_Tags %>"></asp:Literal></h3>
                           <fieldset class="set">
                               <ol class="setIn">
                                   <li class="tags">
                                       <sf:ContentTagEditor ID="itemTagEditor" runat="server" />
                                   </li>
                               </ol>
                           </fieldset>
                       </ItemTemplate>
                   </sfGCn:ContentMetaFields>


    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  14. Joel Kinzel
    Joel Kinzel avatar
    35 posts
    Registered:
    16 Jul 2009
    16 Dec 2010
    Link to this post
    Ivan, it seems to be working now.
Register for webinar
14 posts, 0 answered