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

丶灬走出姿态 提交于 2019-12-03 10:23:37

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)
    {

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

[Route("marketdata//tickerinfo")]

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

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!