Technical support This forum is closed.
Version 1.x > Technical support > Incorrect URL to Files in search result View modes: 
User avatar
Member
Member
Andre van der Hoeven - 1/11/2006 2:40:48 PM
   
Incorrect URL to Files in search result
Hi Petr,
After uploading a file (KenticoCMSTutorial.pdf) into the sample web site, the file is referenced with an incorrect URL in the search result page:

http://localhost/KenticoCMS/Files/KenticoCMSTutorial_pdf.aspx

How can I exclude URLs in the upload directory from being rewritten?
Thanks,
Andre

User avatar
Guest
admin - 1/13/2006 1:21:37 PM
   
Re: Incorrect URL to Files in search result
Hi Andre,

Thank you for your message. You may need to configure the CMSSearchResults control so that it uses the SearchResultRedirect.aspx page. It should look like this:

<cc1:cmssearchresults id="CMSSearchResults1" runat="server" cmssearchdialogid="CMSSearchDialog1" targeturl="~/SearchResultRedirect.aspx?idpath="
usefriendlyurls="False"></cc1:cmssearchresults>

If you would like to exclude some directory or file from URL rewriting and output filter, you can do that using the following web.config parameter:

<add key="CMSExcludedDirectories" value="/registration;/subscriptions" />

Best Regards,

User avatar
Member
Member
Andre van der Hoeven - 1/13/2006 3:12:41 PM
   
Re: Incorrect URL to Files in search result
Hi Petr,
The CMSSearchResults control already uses the SearchResultRedirect.aspx page (I'm using the Sample Corporate site). So, the actual search result URL is:

http://localhost/KenticoCMS/SearchResultRedirect.aspx?idpath=/20/115

which redirects to:

http://localhost/KenticoCMS/Files/KenticoCMSTutorial_pdf.aspx

which returns a 404 (resource not found).
Excluding the Files directory:

<add key="CMSExcludedDirectories" value="/ControlsExamples;/Files" />

makes no difference.
I'm using version 1.8.2174, .NET 1.1, C#.
Is Kentico supposed to redirect to a .aspx URL?
Thanks,
Andre

User avatar
Guest
admin - 1/13/2006 3:37:25 PM
   
Re: Incorrect URL to Files in search result
Thank you, Andre. Unfortunately, this is a bug in 1.8 that will be fixed in 1.8a. I'm sorry for the inconvenience.

Here's how you can fix it now: Please edit the SearchResultsRedirect.aspx.cs file, add the marked lines to the code and recompile your web project:

// get nearest parent menu item
if ( ( !( ConfigurationSettings.AppSettings[ "CMSSearchResultToNearestPage" ] == null ) ) && ConfigurationSettings.AppSettings[ "CMSSearchResultToNearestPage" ].ToLower().Trim() == "true" && node.ClassName.ToLower() != "cms.menuitem" ) {
pageDR = Functions.GetPageInfoDR( Functions.RemoveCultureFromPath( System.Convert.ToString( node.GetValue( "AliasPath" ) ) ) );
if ( !( pageDR == null ) ) {
// page found
newAliasPath = System.Convert.ToString( pageDR[ "AliasPath" ] );
}
else {
// page not found - it's root
if ( node.ClassName.ToLower() == "cms.file" ) {
// redirect directly to the file
newAliasPath = node.GetParentPath( TreePathTypeEnum.AliasPath ) + "/" + System.Convert.ToString( node.GetValue( "FileName" ) );
addExtension = false;
}
else {
// redirect to home page
newAliasPath = "/";
}
}
}
else {
// *********************************** here starts the code to be added ********** //
if ( node.ClassName.ToLower() == "cms.file" )
{
// redirect to the file through the getfile.aspx page
Response.Redirect("~/getfile.aspx?nodeid=" + (int)(node.GetValue("NodeID")));
}
// *********************************** here ends the code to be added ********** //

newAliasPath = System.Convert.ToString( node.GetValue( "AliasPath" ) );
}

Please let me know if you need any help with that.

Best Regards,

User avatar
Member
Member
Andre van der Hoeven - 1/13/2006 3:52:25 PM
   
Re: Incorrect URL to Files in search result
That solved the problem.
Thanks!
Andre