Home > Net >  Net core 3.1 how to set the API access to the method name
Net core 3.1 how to set the API access to the method name

Time:11-24

Now.net 3.1 webapi rest in routing way inside the core standards, through the access method match, I set up 2 the get method, complains, could you tell me how to set up and can be accessed through the method name,

Such as controller named User method called GetUsers
Access to http://* * *. Com/API/user/getusers

thank you

CodePudding user response:

How before, now, still don't have special statement is.net core 3.1
Have been so from the first edition of webapi, please change the default routing, please take the action, not the action of routing can not set up multiple get

CodePudding user response:

 
Endpoints. MapControllerRoute (
Name: "default",
The pattern: "{controller=Home}/{action=Index}/{id? } ");


This is not all to bring the action?

CodePudding user response:

Core nearly broke the traditional asp.net MVC/web API framework to integrate in, development way almost unchanged, can be configured routing template or format to specify the path using Route features,

CodePudding user response:

But I again official documents, and found no configuration in different ways, may be I don't find the right, who is understanding, also please note that

CodePudding user response:

3.1 are not ripe, 2 x should be similar to # 2 way, or, in front of the controller are defined routing:
 [Route (" API/[controller]/[action] ")] 
Public class XXXController

CodePudding user response:

Is configured routing,
The route set {controller}/{action}/{id}
  • Related