routing

Web API Routing - api/{controller}/{action}/{id} “dysfunctions” api/{controller}/{id}

…衆ロ難τιáo~ 提交于 2019-11-27 17:04:23
I have the default Route in Global.asax: RouteTable.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = System.Web.Http.RouteParameter.Optional } ); I wanted to be able to target a specific function, so I created another route: RouteTable.Routes.MapHttpRoute( name: "WithActionApi", routeTemplate: "api/{controller}/{action}/{id}", defaults: new { id = System.Web.Http.RouteParameter.Optional } ); So, in my controller, I have: public string Get(int id) { return "object of id id"; } [HttpGet] public IEnumerable<string> ByCategoryId(int id) { return

Using Routing without MVC: authentication form

不问归期 提交于 2019-11-27 16:59:41
问题 Now I'm trying to work with System.Web.Routing. All is just fine, but I can't understand how to make form authentication work with url routing (return url, redirection, etc). Google says nothing. Help! :) UPD: I forgot - I don't use MVC . That's the problem. How to use rounig and form authentication without MVC UPD2: more about my problem What I want to get: urls such “ mysite.com/content/123 ”, “ mysite.com/login/ ”, etc using Routes. It’s important to make login page works like “regular”

laravel routing and 404 error

旧街凉风 提交于 2019-11-27 16:49:58
问题 I want to specify that if anything entered in the url address other than existing routes (in routes.php, then show 404 page. I know about this: App::abort(404); but how can I specify the part where everything else except the routes defined? 回答1: You can add this to your filters.php file: App::missing(function($exception) { return Response::view('errors.missing', array(), 404); }); And create the errors.missing view file to show them the error. Also take a look at the Errors & Logging docs

Angular 4 Routing not working on live web-app

半世苍凉 提交于 2019-11-27 16:46:59
问题 My Angular 4 web-app routing works fine in my dev environment, and the menu redirects work fine on the live version. However, the dev version redirects to different pages by typing in the address field of the browser, but the live version doesn't. Is this an Angular problem? Or do I need to manage my redirects with my ISP? My app.router.ts code is as follows: import { ModuleWithProviders } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { HomeComponent }

How do I remove the Devise route to sign up?

折月煮酒 提交于 2019-11-27 16:41:22
I'm using Devise in a Rails 3 app, but in this case, a user must be created by an existing user, who determines what permissions he/she will have. Because of this, I want: To remove the route for users to sign up . To still allow users to edit their profiles (change email address and password) after they have signed up How can I do this? Currently, I'm effectively removing this route by placing the following before devise_for :users : match 'users/sign_up' => redirect('/404.html') That works, but I imagine there's a better way, right? Update As Benoit Garret said, the best solution in my case

symfony2 use multiple url pattern for a single Controller Action using regular expression

隐身守侯 提交于 2019-11-27 16:03:18
问题 Is that possible with symfony2 to define multiple url patterns for a single Controller Action using regular expressions, so we don't have to define several rules ? Thanks in advance 回答1: Do you mean placeholders with requirements? blog: pattern: /blog/{page} defaults: { _controller: AcmeBlogBundle:Blog:index, page: 1 } requirements: page: \d+ Here you have multiple routes defined by a placeholder, validated by regular expressions going to the same controller action. Edit: Each part of the url

Node.js Express route naming and ordering: how is precedence determined?

梦想与她 提交于 2019-11-27 15:59:35
Say I've got a few GET routes on my Express application: // music albums app.get('/api/albums', routes.albums.getAlbums); app.get('/api/albums/:id', routes.albums.getAlbum); app.get('/api/albums/artwork', routes.albums.getAlbumArtwork); and I attempt to hit them using the follow jQuery AJAX snippet: $("#retrieveAlbumArtwork").on("click", function() { $.ajax({ url: "api/albums/artwork", type: "GET", data: { artist: $("#albumArtist").val(), title: $("#albumTitle").val() }, // ... callbacks and such For some reason, this call hits the second handler, with the /:id parameter, instead of the

Using the correct url_for method in a Rails engine spec

隐身守侯 提交于 2019-11-27 15:55:27
问题 I have a request spec in a Rails engine. The view that is rendered calls a route and passes in a hash, i.e. projects_path(:scope => "user") . A route like this will eventually call url_for , but url_for is defined in many places. When running the application or running a request spec in the main app (root level), the call chain ends up at ActionView::RoutingUrlFor#url_for ; when running a spec in the engine, however, the call chain ends up at ActionView::Helpers::UrlHelper#url_for . In Rails

WebAPI route 404's when there is a trailing space in the URL

萝らか妹 提交于 2019-11-27 15:08:59
With the default web api route config.Routes.MapHttpRoute( name: "API Default", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); and a controller public class TestController : ApiController { [HttpGet] public HttpResponseMessage Get(string id) { return Request.CreateResponse(HttpStatusCode.OK, id); } } A request to 'api/test/1' returns 1 If for some reason you send a request to 'api/test/1%20' the route 404's. Now this example may seem silly since browsers trim trailing spaces, but for a route like 'api/{controller}/{id}/{extrastuff}' the space in '1 '

Asp.Net Routing: How do I ignore multiple wildcard routes?

风流意气都作罢 提交于 2019-11-27 15:08:12
I'd like to ignore multiple wildcard routes. With asp.net mvc preview 4, they ship with: RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); I'd also like to add something like: RouteTable.Routes.IgnoreRoute("Content/{*pathInfo}"); but that seems to break some of the helpers that generate urls in my program. Thoughts? Haacked There are two possible solutions here. Add a constraint to the ignore route to make sure that only requests that should be ignored would match that route. Kinda kludgy, but it should work. RouteTable.Routes.IgnoreRoute("{folder}/{*pathInfo}", new {folder="content