Quantcast
Channel: ASPNETWebStack Issue Tracker Rss Feed
Viewing all articles
Browse latest Browse all 7215

Closed Issue: Self link doesn't support guid or other special types as primary key [499]

$
0
0
If user uses guid property as primary key, the generated self link looks like:
http://localhost:9001/GuidPrimaryKeyType(guid'1a2398cd-32e9-46f1-b702-3c671ceb8f6d')

However, we don't have correct model binding to parse the guid'1a2398cd-32e9-46f1-b702-3c671ceb8f6d' as Guid clr type. So the server will report an error when parsing it.

The issue doesn't only apply for Guid. It applies to any other types other than integer.

For string primary key, model binding will include single quote in id parameter. A workaround is to add an additional route:
configuration.Routes.MapHttpRoute("GetByStringId", "{controller}('{id}')");

The same issue should apply for datetime, long, decimal, double, float as well.

Since GUID, long and string are very common as primary key, I think this issue having high impact.
Comments: Verified in latest build

Viewing all articles
Browse latest Browse all 7215

Trending Articles