The route template separator character '/' cannot appear consecutively - Attribute routing issue

前端 未结 4 1891
长情又很酷
长情又很酷 2021-02-05 01:04

The configuration has nothing to do with the error

This is my configuration for the Web API in App_Start/WebApiConfig.cs:

public static void Register(H         


        
相关标签:
4条回答
  • 2021-02-05 01:18

    I was receiving this issue with a combination of a [RoutePrefix] and a [Route] on an action.

    [RoutePrefix("/api/my/application")]
    

    on the action I had

    [HttpPost, Route("{someVariable:int}"]
    

    When I changed: [RoutePrefix("/api/my/application")]to[RoutePrefix("api/my/application")] everything was fine.

    0 讨论(0)
  • 2021-02-05 01:29

    I've got the same error with two (or more) slashes.

    [Route("marketdata//tickerinfo")]
    

    It's easy to happen when you change the string.

    0 讨论(0)
  • 2021-02-05 01:39

    The reason for the above error is that I am using an additional '/' in the route attribute for the action. The action defined in the above controller should be as follows:

        [HttpGet]
        [Route("marketdata/tickerinfo")]
        public IHttpActionResult TickerInfo(string currencyPair)
        {
    
    0 讨论(0)
  • 2021-02-05 01:42

    I got the same error however it was caused by the ActionName attribute in my case.

    [ActionName("")]
    public void Get(string code)
    

    Although this broke the Help pages I was still able to reach the endpoint api/controller?code=123. When I removed the ActionName attribute the error disappeared.

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