2

在 ASP.NET 核心中创建路由的正确语法是什么?

        app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "default",
                template: "{controller=Home}/{action=Index}/{id?}");

            routes.MapRoute(
                name: "Handoff-iOS9",
                //url: ".well-known/apple-app-site-association",
                template: "{controller=Home}/{action=WellKnownAppleHandoff}" );

            routes.MapRoute(
               name: "ApplePay",
               //url: ".well-known/apple-developer-merchantid-domain-association",
               template: "{controller=Home}/{action=WellKnownApplePay}");
        });
4

1 回答 1

4

这是诀窍

      app.UseMvc(routes =>
        {
            routes.MapRoute(
                name: "Handoff-iOS9",  
                template: ".well-known/apple-app-site-association",
                defaults:  new { controller = "Home", action = "WellKnownAppleHandoff" });

            routes.MapRoute(
                name: "ApplePay-MacOS",
                template: ".well-known/apple-developer-merchantid-domain-association",
                defaults: new { controller = "Home", action = "WellKnownApplePay" });

            routes.MapRoute(
              name: "default",
              template: "{controller=Home}/{action=Index}/{id?}");

        });
于 2016-09-05T16:12:52.657 回答