How can I control the base URL attribute in the root element of an OData service document?
I\'m setting up an OData service using WebApi, the System.Web.Http.OData.B
I had the same problem with PowerPivot and I managed to fix the xml:base to be compatible with it. Here's the part of the code needed:
class MyODataPathHandler : DefaultODataPathHandler
{
public override string Link(ODataPath path)
{
if (path.PathTemplate == "~")
{
return path.ToString() + "/";
}
return base.Link(path);
}
}
and
config.Routes.MapODataRoute("odata", "odata", builder.GetEdmModel(), new MyODataPathHandler(), ODataRoutingConventions.CreateDefault());
the custom ODataPathHandler will add the extra slash for the default path, which results in an xml:base that works around the bug in PowerPivot. The second issue is PowerPivot expects data in XML, not in JSON. One workaround for that can be found at http://aspnetwebstack.codeplex.com/workitem/820