Code Monkey home page Code Monkey logo

Comments (4)

xuzhg avatar xuzhg commented on May 26, 2024 1

@gathogojr Since it's related to your post, would you please take a look?

from aspnetcoreodata.

sunliangqin avatar sunliangqin commented on May 26, 2024 1

Sorry for the beginner questions. After switching to the Odata attribute routing. It worked for me. Thanks both for the help!

from aspnetcoreodata.

xuzhg avatar xuzhg commented on May 26, 2024

RouteAttribute is not used in OData attribute routing.
OData attribute routing is using [ODataRouteAttribute] and [ODataRoutePrefixAttribute].

from aspnetcoreodata.

gathogojr avatar gathogojr commented on May 26, 2024

@sunliangqin I hope you're able to make a distinction between following three things:

  • ASP.NET Core attribute routing (using RouteAttribute - Route in short form),
  • OData attribute routing (using ODataRouteAttribute and ODataRoutePrefixAttribute - ODataRoute and ODataRoutePrefix in short form respectively)
  • Endpoint routing

Actions are either conventionally-routed or attribute-routed. Placing a route on the controller or the action (like you have done above) makes it attribute-routed, not endpoint-routed. However, you can either call MapControllers inside UseEndpoints to map attribute-routed controllers or call MapControllerRoute to map both conventionally-routed controllers and attribute-routed controllers.

You can read more about ASP.NET Core routing here and OData attribute routing here

I have added a sample service to the repo with endpoint routing enabled. If you changed this line in the client project,
from:

var serviceUri = new Uri("http://localhost:8302/odata");

to

var serviceUri = new Uri("http://localhost:1538/api");

you'll find everything works the same, with endpoint routing enabled.

from aspnetcoreodata.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.