Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Data URL Routing: Short URLs cannot be resolved 60 seconds after last use. #339

Closed
DBailey635 opened this issue Jan 12, 2017 · 6 comments
Closed
Assignees

Comments

@DBailey635
Copy link

DBailey635 commented Jan 12, 2017

I have a Page Datafolder with the Short URL name set as "buildings". I have also created a Razor function for my Building page (at ~/Our-Buildings) which enables Data URL Routing using the RoutedData<T> type.

According to the documentation, this means that I can link to the routed page using just this:

<a href="~/buildings(Id)">link</a>

... where the Id is a valid GUID for the datatype record.

Most of the time this works fine. If I link to a datatype record from another page in my website, the page rendering engine resolves the link stored in the page to the correct URL: ~/Our-Buildings/Main-House

However, If I haven't browsed to the page at ~/Our-Buildings (or one of the datatype record pages) for 60 seconds, the URL isn't resolved any more by the page rendering engine... i.e. the when I use "view source" in my browser, the URL remains as ~/buildings(Id).

In other words, it appears that Short URLs are only cached for 60 seconds, before being forgotten by the rendering engine. Is there a way to fix this so that I can consistently use these ~/building(Id) links?

@napernik
Copy link
Contributor

napernik commented Feb 7, 2017

Hi David

You can register the internal url (~/buildings(id)) to actual url on startup instead of relying for the cms to discover the binding.

A code example can be found here:

http://docs.cms.orckestra.com/Data/Linking-to-Data-Items/Internal-Data-Link-Formats#Internal-Linking-for-Static-Data-Types

Something like:
DataUrls.RegisterGlobalDataUrlMapper(RoutedData.GetRoutedByIdDataUrlMapper(buildingsPageId, typeof(IBuilding)));

@DBailey635
Copy link
Author

I've just updated to C1 v6.2, and I'm still seeing RoutedData<T> type ~/shorturl(Id) URLs failing to resolve 60 seconds after the destination page was last loaded. Something is dropping out of memory somewhere.

This is occuring for Page Datafolder datatypes loaded via a Razor functions like this one:

@inherits RazorFunction
@using System.Linq
@using Composite.Core.Routing.Pages
@using System.Threading;

@functions {
    public override string FunctionDescription
    {
        get { return "Lists the courses or shows the full content of a single course item when selected."; }
    }

    [FunctionParameter(Label = "Items to display", Help = "How many courses should be displayed per page?", DefaultValue = "10")]
    public int MaximumItemsPerPage { get; set; }

    public RoutedData<BaileyWeb.University.Courses> course { get; set; }
}

@if (course.IsItem)
{
	<f:function name="BaileyWeb.University.Courses.ShowCourseDetailById" xmlns:f="http://www.composite.net/ns/function/1.0">
		<f:param name="CourseId" value="@course.Item.Id" />
	</f:function>
}
else
{
	<f:function name="BaileyWeb.University.Courses.ShowCourseFinderResults" xmlns:f="http://www.composite.net/ns/function/1.0">
		<f:param name="Debug" value="False" />
		<f:param name="MaximumItemsPerPage" value="@MaximumItemsPerPage" />
	</f:function>
}

Do I need to add something else? I'm finding the documentation a bit vague.

@mawtex
Copy link
Collaborator

mawtex commented Sep 12, 2017

Is the Razor function added to the page that has the data folder below it, and will the function always run?

@mawtex mawtex reopened this Sep 12, 2017
@DBailey635
Copy link
Author

Yes, and Yes.

@napernik
Copy link
Contributor

No, it shouldn't make a difference.

@napernik
Copy link
Contributor

I tried reproducing the issue without any success. There're a few limitations I've found out -> a web request is used internally to execute related pages. So if site isn't reachable via hostname from the server where it is hosted, or the site is load balanced, the feature may not work as intended.

It would be better to render the page internally without going through network, but it would be much easier to achieve once we got rid of WebForms handler we are using now, I will take another look at it once we have "rendering without ASP.NET web forms feature" down.

I've added some extra logging that can help should the problem be related to rendering a page.
Otherwise - the must be another trigger or configuration to the issue rather than only time.

The workaround I've mentioned in the comments previously should help (registering the url route on startup with C#)

@mawtex mawtex closed this as completed in 38935d9 Dec 4, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants