// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, ILoggerFactory loggerFactory) { loggerFactory.AddConsole(minLevel: LogLevel.Verbose); app.UseIISPlatformHandler(); var routeBuilder = new RouteBuilder(); routeBuilder.ServiceProvider = app.ApplicationServices; routeBuilder.Routes.Add(new TemplateRoute( new HelloRouter(), "hello/{name:alpha}", app.ApplicationServices.GetService<IInlineConstraintResolver>())); var endpoint1 = new DelegateRouter(async (context) => await context .HttpContext .Response .WriteAsync("Hello world! Route Values: " + string.Join("", context.RouteData.Values))); routeBuilder.DefaultHandler = endpoint1; routeBuilder.MapRoute( "Track Package Route", "package/{operation:regex(track|create|detonate)}/{id:int}"); app.UseRouter(routeBuilder.Build()); // demonstrate link generation var trackingRouteCollection = new RouteCollection(); trackingRouteCollection.Add(routeBuilder.Routes[1]); // "Track Package Route" app.Run(async (context) => { var dictionary = new RouteValueDictionary { {"operation","create" }, {"id",123} }; var vpc = new VirtualPathContext(context, null, dictionary, "Track Package Route"); context.Response.ContentType = "text/html"; await context.Response.WriteAsync("Menu<hr/>"); await context.Response.WriteAsync(@"<a href='" + trackingRouteCollection.GetVirtualPath(vpc).VirtualPath + "'>Create Package 123</a><br/>"); }); }