routing

Web Api Core 2 distinguishing GETs

一曲冷凌霜 提交于 2019-12-08 03:54:50
问题 Why can't Web API Core 2 tell these apart? [HttpGet] public IEnumerable<string> Get() { return new string[] { "value1", "value2" }; } // GET api/values?name=dave [HttpGet] public string Get(string name) { return $"name is {name}"; } Here's what happens - Both http://localhost:65528/api/values and http://localhost:65528/api/values?name=dave cause the first Get() method to execute. This exact code works fine in Web Api 2. I know multiple ways of getting around this, but I don't know why it

Rails dynamic error pages (404, 422, 500) showing as blank

元气小坏坏 提交于 2019-12-08 03:51:14
问题 I'm implementing dynamic error pages into an app, and have a feeling it's looking in the public folder for (now non-existent) templates, rather than following the routes I've set up. In config/application.rb I've added the line config.exceptions_app = self.routes to account for this. I've then added the following to my routes: get "/not-found", :to => "errors#not_found" get "/unacceptable", :to => "errors#unacceptable" get "/internal-error", :to => "errors#internal_error" And the errors

Trouble filtering in Camel

孤者浪人 提交于 2019-12-08 03:40:13
问题 I am attempting to filter out the null bodies from my route. The route polls from the function every half second or so. So, I get this error in my console also every half-second. Here is the stack trace: Message History --------------------------------------------------------------------------------------------------------------------------------------- RouteId ProcessorId Processor Elapsed (ms) [route1 ] [route1 ] [browserBean ] [ 0] [route1 ] [filter1 ] [filter[simple{(${body} == null)}] ]

Symofny2 Get a listing of available Logical Controller Names

Deadly 提交于 2019-12-08 03:25:23
问题 I need to show a choice with a list of all available controllers as Logical Controller Names AcmeBundle:ControllerName:ActionName I see that CLI command php app/console router:debug dumps a similar listing, but with controller names, e.g. fos_user_security_login . How can I ask Symfony for their Logical Controller Name representation? Thanks! 回答1: As @hous said, this post was useful, but incomplete and its accepted answer misleading. A) Getting the controllers With this code I get all

Flask: Handle catch all url different if path is directory or file

扶醉桌前 提交于 2019-12-08 03:06:29
问题 How can I make a catch all route, that only handles directories and one that handles files? Below is a simple example from flask import Flask app = Flask(__name__) @app.route('/foo') def foo_file(): return 'Queried: foo file' @app.route('/foo/') def foo_dir(): return 'Queried: foo dir' @app.route('/<path:path>') def file(path): return 'Queried file: {0}'.format(path) @app.route('/') @app.route('/<path:path>/') def folder(path): return 'Queried folder: {0}'.format(path) if __name__ == '__main_

How to get a trailing slash appended to page routes?

别等时光非礼了梦想. 提交于 2019-12-08 03:00:17
问题 This is a near identical problem I am having to that of this query, albeit mine is a Web Forms scenario (using routing in .NET 4) as opposed to MVC. Add a trailing slash at the end of each url? The solution that someone mentions there is only half provided unfortunately as the link to the complete solution is broken. At the moment, any trailing slash from my page routes is removed when I get the route url. This is especially problematic when I want to use the following type of inline syntax

Rails 4 - explicit model name for resource id route

吃可爱长大的小学妹 提交于 2019-12-08 02:51:30
问题 When defining the following route in routes.rb : resources :streams Rails generates the following urls: streams GET /streams(.:format) POST /streams(.:format) new_stream GET /streams/new(.:format) edit_stream GET /streams/:id/edit(.:format) stream GET /streams/:id(.:format) PATCH /streams/:id(.:format) PUT /streams/:id(.:format) DELETE /streams/:id(.:format) I would like to have an explicit resource id, i.e. :stream_id instead of :id . edit: For simple resources the solution is like

ASP.NET MVC subdirectories

大城市里の小女人 提交于 2019-12-08 02:11:52
问题 I'm still kind of new to MVC, so I'm hoping this is simple. I need categories and subcategories, potentially multiple levels deep, and I'm trying to organize my project appropriately. Right now I'm using the out-of-the-box MVC project in VS2008. For example, suppose I want to navigate to: http://mysite.com/Products/Electronics/Computers/Laptops I can accomplish this by putting a LaptopsController in my Controllers directory, a Latops directory with the various aspx files in my Views, and

MVC 3 Routing and Action Links not following expected contextual Route

我与影子孤独终老i 提交于 2019-12-08 02:05:53
问题 I'm attempting to do a custom route so I can prefix a url in my application with a chosen string and the do some processing based on that. The problem I'm running into is, that the action links that are generated are not contextualized based on the url that it exists on. Routes: routes.MapRoute( "TestRoute", "TEST/{controller}/{action}/{id}", new { controller = "Space", action = "Index", id = UrlParameter.Optional }); routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller

Angular router: ignore slashes in path parameters

我怕爱的太早我们不能终老 提交于 2019-12-08 01:39:24
问题 I have dynamic routes that could contain slashes or anti-slashes inside parameters , for example: http://localhost:4200/dashboard/T64/27D I should navigate to a page with route T64/27D Here's how I navigate this.router.navigate(['dashboard/'+this.groupListPage[0].code]); this.groupList[0].code contain T64/27D Actually Angular separate T64 and 27D as 2 different pages. Here's the error: ERROR Error: Uncaught (in promise): Error: Cannot match any routes. URL Segment: 'dashboard/T64/27D' Error: