mccalltd / AttributeRouting

Define your routes using attributes on actions in ASP.NET MVC and Web API.
http://mccalltd.github.io/AttributeRouting/
MIT License
416 stars 89 forks source link

Routes.axd graceful failure #239

Open LordRiffRaff opened 11 years ago

LordRiffRaff commented 11 years ago

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() } )));
                    }
                }
mccalltd commented 11 years ago

Wanna submit a pull request for this?

LordRiffRaff commented 11 years ago

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.

mccalltd commented 11 years ago

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.

LordRiffRaff commented 11 years ago

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