Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: Composite 4.1 Bug??

$
0
0
There seems to be a fundamental change in the way Composite renders pages in 4.1 vs 4.0 that breaks pages that have the same function multiple times. You can see it with a pretty trivial example. Create a Razor Function that looks like this:

@functions {
public override string FunctionDescription
{
    get { return "Shows the bug."; }
}

[FunctionParameter(Label = "Title", Help = "The title to display.", DefaultValue = "")]
public string Title { get; set; }

[FunctionParameter(Label = "Strings", Help = "Enter a comma separated list i.e. abc,123,def")]
public string Strings { get; set; }
}

@{
int randId = new Random().Next(); //so we can have multiple on one page.

var strs = Strings.Split(",".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).Select(m => m.Trim()).ToList();

if (!strs.Any()) { return; }
}

<html><body>
@if (!String.IsNullOrEmpty(Title))
{
    <h3>@Title -- @randId</h3>
}
</body></html>


put 2 or more (easier to see with more) of these functions on a C1 Page.

The major difference is that @randId is always the same with 4.1 because it looks as if the functions are now being loaded in parallel vs. serially. So you can't have the same function on the page more than once depending on your scenario. You can change @randID from an int to a GUID.ToString() which seems to solve that problem.

Some times @randId will be different but just refresh the page to see the issue.

However, when running on localhost you also get various errors like:

Error: Object reference not set to an instance of an object.
for if (!strs.Any()) { return; }

Error: Object reference not set to an instance of an object.
Randomly.

It will just work sometimes as well which is a bit weird.


I can't repro the "Error"s on Windows Azure but it's a bit concerning that it happens on Local host. If possible, can someone confirm they see the same behavior?

Thanks.

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>