Remove trailing slash for images

KRISHNA PRASAD E G asked on April 7, 2014 01:03

I am using Kentico CMS 7. I have uploaded images to cms folder as well as db. I need to get trailing slash for all url except urls having extensions. Its working fine for me. But along with this the images that uploaded to db (ie. url like "http://www.mydomail.com/getattachment/test/tes.png/). Here I don't want to use trailing slash.

Recent Answers


Brenden Kehren answered on April 7, 2014 06:37

Have you tried using this key in your web.config? <add key="CMSUseTrailingSlashOnlyForExtensionLess" value="true" /> If there is an extension then it doesn't add the trailing slash.

0 votesVote for this answer Mark as a Correct answer

KRISHNA PRASAD E G answered on April 7, 2014 08:22

Yes I have tried that one.

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 7, 2014 12:12

What were your results? Are you using true extensionless URLs? Are those physical files you are working with or are they handled within the CMS? If physical files that are not uploaded or handled within the CMS, you may need to exclude that directory from CMS processing.

0 votesVote for this answer Mark as a Correct answer

KRISHNA PRASAD E G answered on April 7, 2014 13:01

I am handling my files through CMS. I have uploaded an image to test page through CMS. Its showing url as http://www.mydomain.com/getattachment/test/test.png/. When I am removing the trailing slash its giving 404 error. Which Directory I need to exclude? How can I do that?

0 votesVote for this answer Mark as a Correct answer

Brenden Kehren answered on April 8, 2014 12:01

Looks like you might be using the GetAttachment page wrong. I believe that accepts a GUID and not a path. What method are you using in your transformation?

0 votesVote for this answer Mark as a Correct answer

KRISHNA PRASAD E G answered on April 16, 2014 08:13

Hi

I am using the below mentioned code.

        DataSet ds = null;
        CMS.DocumentEngine.TreeProvider tree = new CMS.DocumentEngine.TreeProvider();            
        ds = tree.SelectNodes(CMSContext.CurrentSite.SiteName, "/%", "en-us", true, "custom.myimages", "", "NodeOrder");
        if (ds != null && ds.Tables[0].Rows.Count > 0)
        {                
            litImage.Text = "<a href='/getattachment/" + ds.Tables[0].Rows[0]["img"].ToString().ToLower() + "/" + ds.Tables[0].Rows[0]["NodeAlias"].ToString().ToLower() + "' target='_blank'>Click here</a>";
        }
0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.