routing

How do you send a request with the “DELETE” HTTP verb?

久未见 提交于 2019-11-29 01:15:03
问题 I'd like to create a link in a view within a Rails application that does this... DELETE /sessions How would I do that. Added complication: The "session" resource has no model because it represents a user login session. CREATE means the user logs in, DESTROY means logs out. That's why there's no ID param in the URI. I'm trying to implement a "log out" link in the UI. 回答1: Correct, browsers don't actually support sending delete requests. The accepted convention of many web frameworks is to send

AngularJs UI router - one state with multiple URLs

偶尔善良 提交于 2019-11-29 00:28:50
问题 I have a request to add in another URL parameter that directs to a state that I already have set up. For efficiency purposes, I'm trying to see if I can add multiple URLs to point to the same state, or should I just use the $UrlRouterProvider.when() method to re-direct to that state in this new case. Ex. this is what already exists .state('site.link1', { url: '/link1', templateUrl: '/views/link1.html', controller: 'link1Ctrl' }) and the request is to add www.site.com/newlink that points to

How to make IRouteConstraint filter route

安稳与你 提交于 2019-11-28 23:17:25
I wrote a custom route constraint, but its filter just doesn't get recognized. Does anyone have an example working use of IRouteConstraint ? Also, note to developers: I get double display of the form on my android. Something must be wrong with the partial rendering? Here's a simple constraint that looks up an article slug in a fictional repository: public class SlugRouteConstraint : IRouteConstraint { private readonly ISlugRepository slugRepository = new SlugRepository(); public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values,

Rails 3 resource routing without an id

一曲冷凌霜 提交于 2019-11-28 22:43:50
问题 I am creating a blog application on Rails 3, and I want to override the default show route generated for a post by doing resources :posts, :except => :show Which generates, for the show route (had I not excluded it), /post/:id I want my route to look like this instead, where url_title is a string generated by my model on before_save, where it removes non alphanumeric characters and replaces spaces with hyphens. /:year/:month/:day/:url_title I'm trying to accomplish this with this bit of code:

Angular 2 feature module routing example

陌路散爱 提交于 2019-11-28 22:22:38
问题 As far as Angular 2 routing goes, I've mostly been able to find examples of the scenario where there's exactly one routing file for the whole application. I'd like to see an example of using not just one routing file, but a main routing file and then at least one feature module routing file. Edit : I realize that a somewhat similar question has already been asked and answered. There are two reasons why I don't find that one particularly helpful: 1) The question is very specific to that user's

Postback not working with ASP.NET Routing (Validation of viewstate MAC failed)

谁说胖子不能爱 提交于 2019-11-28 22:06:33
I'm using the ASP.NET 3.5 SP1 System.Web.Routing with classic WebForms, as described in http://chriscavanagh.wordpress.com/2008/04/25/systemwebrouting-with-webforms-sample/ All works fine , I have custom SEO urls and even the postback works. But there is a case where the postback always fails and I get a: Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster. Here is the scenario to reproduce the error: Create a standard webform

Routing with an optional parameter

China☆狼群 提交于 2019-11-28 21:56:29
问题 I added in the route file: map.show_book "/show_book/:name/year/:year", :controller => "book", :action => "show_version" I also added: map.show_book "/show_book/:name", :controller => "book", :action => "show_version" to show the latest book without specifying the year. But it doesn't work, it cannot find the route in "show_book/NAME" if I don't pass the year. Do you have some ideas why it doesn't work ? THANKS ! PS. I know that I can use year as parameter with "?year=XXXX", but I want to use

Render controller action from another controller

本秂侑毒 提交于 2019-11-28 21:12:25
I think the code is more explicit option A class RedirectController < ApplicationController def index redirect_to :controller => 'posts', :action => 'show', :id => 1 # it works end end option B class RedirectController < ApplicationController def index render :controller => 'posts', :action => 'show', :id => 1 # it doesn't work end end Is possible in (B) to load another action in another controller? (and not just the view) How? Thanks Bohdan Try render 'posts/show' or render :template => 'posts/show' Just render the template def index render 'posts/show' end This one also works def index

Can someone explain asp.net routing syntax to me?

£可爱£侵袭症+ 提交于 2019-11-28 21:12:20
I am dealing with this code in a Web Forms scenario: public static void RegisterRoutes(RouteCollection routes) { Route r = new Route("{*url}", new MyRouteHandler()); routes.Add(r); routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.gif/{*pathInfo}"); } Firstly, can anyone tell me where the defintion of {*pathInfo} is? http://msdn.microsoft.com/en-us/library/cc668201.aspx#url_patterns doesn't really define it. Does: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); Match /c/xyz.axd and /b/c/xyz.axd and /a/b/c/xyz.axd Whereas routes.IgnoreRoute("{resource}.axd");

CodeIgniter Routing

早过忘川 提交于 2019-11-28 20:57:31
I am developing an ecommerce website with CI that has product categories and products. I want to route the URL so that it will go to the products controller, then run the getCategoryByName function for the first segment, then run the getProductByName for the second segment. Here is what I have: URL: products/docupen/rc805 routes.php: $route['products/([a-z]+)'] = "products/getCategoryByName/$1"; $route['products/([a-z]+)/([a-z0-9]+)'] = "products/$1/getProductByName/$2"; But its not working. "docupen" is the category, and "rc805" is the product. Thanks in advance. Thank you all for your help.