Is it possible to expose multiple Odata v4 endpoints in Asp.Net WebApi project

前端 未结 1 1907
被撕碎了的回忆
被撕碎了的回忆 2021-01-16 21:51

The title explains the requirement. Is it possible to expose multiple endpoints in single project?

Something like:

  • http://localhost:8000/svc1/$metadata
相关标签:
1条回答
  • 2021-01-16 22:10

    The following line should be the one you care about:

    config.MapODataServiceRoute("Odata", "Odata", GenerateEdmModel(), batchHandler);
    

    The second string parameter is the routePrefix, which means currently you're probably hitting http://yourhost.com/Odata/$metadata. If you simply create another mapping with a different prefix value (e.g. Odata2) you'd be able to make calls against http://yourhost.com/Odata/$metadata AND http://yourhost.com/Odata2/$metadata. You'll probably want to give them both a unique routeName as well though (the first string parameter), and you'll probably want to provide a different model as well so the two services will actually be different :).

    0 讨论(0)
提交回复
热议问题