Tuesday, July 5, 2016

Sitecore search ashx is appearing in search result URLs

I noticed that in some cases a Lucene search that I had built in Sitecore was generating URLs that contained a .ashx extension for PDF files in some cases and .pdf in others.

There is a setting in the Sitecore.config file which controls which extension will be shown for media library URLs. The setting is Media.RequestExtension and by default will be set to ashx.
<setting name="Media.RequestExtension" value="ashx"/>
Using a patch file (or editing directly), simply set this to an empty value to ensure media library content is served up using the correct extension.

However in my case, this did not resolve the issue... Some items were still coming through with .ashx and there was no content differences that could cause this issue. Ultimately setting IncludeExtension in the MediaUrlOptions did solve it:
itemUrl = MediaManager.GetMediaUrl(item, new MediaUrlOptions { AlwaysIncludeServerUrl = true, IncludeExtension = true});

No comments:

Post a Comment