首页 > 解决方案 > 为什么 ASP.NET Core MVC 路由无法匹配“//”如“https://localhost:5001//?id=123”?

问题描述

ASP.NET MVC 框架可以//https://localhost:5001//?id=123. 但是 ASP.NET Core MVC 不能。这是我在 ASP.NET Core MVC 中的默认路由:

    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?}");
        });
    }

标签: asp.net-coreasp.net-core-mvcasp.net-routing

解决方案


推荐阅读