DotNetAnalyzers / AspNetCoreAnalyzers

MIT License
62 stars 4 forks source link

Don't use consecutive slash in route #44

Closed JohanLarsson closed 5 years ago

JohanLarsson commented 5 years ago
[HttpGet("api//foo")]
public ActionResult<string> Get()
{
    ...
}
Cisien commented 5 years ago

as far as i know, the browser (or server?) ignore the double slashes, and in this instance is probably a typo

JohanLarsson commented 5 years ago

image

Tested it with:

namespace AspBox.Controllers
{
    using System.Collections.Generic;
    using Microsoft.AspNetCore.Mvc;

    [ApiController]
    public class FoosController : ControllerBase
    {
        [HttpGet("/api//foos")]
        public ActionResult<IEnumerable<string>> Get()
        {
            return new string[] { "value1", "value2" };
        }
    }
}