AttributeRouting icon indicating copy to clipboard operation
AttributeRouting copied to clipboard

Routes.axd graceful failure

Open LordRiffRaff opened this issue 11 years ago • 4 comments

We've been trialing using Umbraco6.1 beta and AttributeRouting and just discovered that the routes.axd doesn't gracefully handle / check the type of the objects inside the DataTokens.

i.e in this particular case the namespaces object had a string rather than a string[] inside it, and was causing routes.axd to YSOD, however the routes themselves to still work. (We've already let the Umbraco team know their end is broken).

So it can be fixed in AttributeRouting->Logging->RouteLogginInfo.cs ala:

~Line 115

                if (token.Key.ValueEquals("namespaces"))
                {
                    if (token.Value is string[])
                    {
                        item.DataTokens.Add(token.Key, String.Join(", ", (string[])token.Value));
                    }
                    else
                    {
                        item.DataTokens.Add(token.Key, String.Join(", ", (new string[] { token.Value.ToString() } )));
                    }
                }

LordRiffRaff avatar Apr 12 '13 02:04 LordRiffRaff

Wanna submit a pull request for this?

mccalltd avatar Apr 19 '13 03:04 mccalltd

Sure I can when I get 30 minutes spare at work to add in some type checking, is this what you want though? I don't know if you're in favour of YSODing when there's invalid incoming data or if you'd prefer to just carry on.

LordRiffRaff avatar Apr 19 '13 03:04 LordRiffRaff

I hear ya about whether to YSOD or carry on. This is def an edge case, and I'm not sure if Umbraco is doing things in a valid way by adding a simple string rather than a string[] in "namespaces". (I would wager they're mucking it up, as the dictionary key is named "namespaces" after all.) But to me I don't think it's a big deal to put in a workaround.

mccalltd avatar Apr 19 '13 03:04 mccalltd

Okay no problem, I'll go submit a pull request when I get into work on monday.

LordRiffRaff avatar Apr 19 '13 03:04 LordRiffRaff