1

The ASP.NET MVC Framework can match up // like https://localhost:5001//?id=123. But ASP.NET Core MVC cannot. This is my route in ASP.NET Core MVC by default:

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
        }
        else
        {
            app.UseExceptionHandler("/Home/Error");
            // The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
            app.UseHsts();
        }
        app.UseHttpsRedirection();
        app.UseStaticFiles();

        app.UseRouting();

        app.UseAuthorization();

        app.UseEndpoints(endpoints =>
        {
            endpoints.MapControllerRoute(
                name: "default",
                pattern: "{controller=Home}/{action=Index}/{id?}");
        });
    }
Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77
  • Are you looking for hostname based routing? If so, you can accomplish that using the (under-documented) `.RequireHost()` method. See [my previous answer on this topic](https://stackoverflow.com/a/61396547/3025856) for details. – Jeremy Caney Jun 11 '20 at 02:34
  • @JeremyCaney I believe they're asking why `//` (**after** the hostname) cannot be used as a route in ASP.NET Core, but it can in ASP.NET MVC. – Dai Jun 11 '20 at 02:38
  • 2
    That said, you shouldn't use double-leading-slashes at all in URIs' paths because there's a lot of infrastructure and tooling that assumes there's only ever 1 leading slash. – Dai Jun 11 '20 at 02:40

0 Answers0