I have an asp.net web API, which is using attributes for routing on controllers. There are no path attriutes at the action level, the path to accessing a resource is: [Root ("{ID}"] Public MyApiController: ApiController {Get Public HttpResponseMessage (GUID ID) { // ...}}
My problem is that when I want to make a search controller, then I should have a URL
  [root ( "Search")]    But this is the result of an error:?  Multiple controller types found that the URL matches  it is sure The exact match path is possible before the selection is made to normal 
 Technically, the phrase  search  can be a valid identity card for the first controller, but As a  {ID}  a GUID, this case will never happen, thus I want to select the controller with the exact match path. 
You can use Route barriers to work . You can disrupt your ID route to accept valid GUIDs for deletion.
 
Public class MyApiController: ApiController {Get Public HttpResponseMessage (GUID ID) {New HTTPPRESS Passwords (HTTPPatus code.OK); }}
 The search controller will match a URL such as  "/ search" . Here is the controller: 
  [System.Web.Http.Route ("search")] Public class SearchController: ApiController {Get Public HttpResponseMessage () {New HttpResponseMessage Return (HttpStatusCode.OK) ; }}   The restriction will stop the matching conflict in the router.
Comments
Post a Comment