routing

Rails 3, Custom Actions, and HTML request methods

廉价感情. 提交于 2019-12-11 03:17:08
问题 I don't really understand the pro's and con's of using "post" vs "get" vs "put" requests, on custom controller actions, and whether to use links or forms/buttons. So let's say I have a simple to-do list with tasks, and a tasks controller, and I want a "complete" action where I find a specific task in the db and update it's status attribute from "incomplete" to "complete." def complete @task = Task.find(params[:id]) if @task.update_attributes(:status => "complete") redirect_to tasks_url,

Create a subdomain alias that only has access to certain pages

我只是一个虾纸丫 提交于 2019-12-11 03:15:34
问题 Background We're running a project for someone that wants a "white-label" solution (they want to have a subdomain of their site that shows certain pages of our site, styled to look like theirs). The main reason we're leaning towards this route is so their users feel like they haven't left the original site (or that they are related) and the client is insistent. Plan Point a subdomain at our server, but only allow it to access the pages relevant to this project (or else our regular site pages

Routing by slug in asp.net mvc

自作多情 提交于 2019-12-11 03:15:32
问题 I have a controller action as you can see below: public ActionResult Content(string slug) { var content = contentRepository.GetBySlug(slug); return View(content); } I want this kind of urls to be routed to my action: http://localhost/slug-of-my-content Here is my RegisterRoutes method: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( name: "Default", url: "{controller}/{action}/{id}", defaults: new { controller =

Angular child route and 404

只愿长相守 提交于 2019-12-11 03:13:17
问题 The route to find nonexistent links does not allow you to go through child links. app-routing.module.ts import { NgModule } from '@angular/core'; import { Routes, RouterModule } from '@angular/router'; import { IntroComponent } from './shared/components/intro/intro.component'; import { NotFoundComponent } from './shared/components/not-found/not-found.component'; import { ReportsComponent } from './reports/reports.component'; import { TrainingComponent } from './training/training.component';

Codeigniter 2.1.4 installation in sub directory

半世苍凉 提交于 2019-12-11 02:33:10
问题 I have successfully installed CI in the root directory many times, but now I have been forced to install CI in https://mydomain.com/mvc There exists one controller "Login" with one action "index" The .htaccess file looks like: Options +FollowSymLinks RewriteEngine on RewriteBase /mvc RewriteRule ^(.*)$ index.php?/$1 [L] In config/config.php $config['base_url'] = 'https://mydomain.com/mvc/'; $config['index_page'] = ''; My routes look like: $route['default_controller'] = "login"; $route['login'

OPTIONS Verb for Routes with custom CORS headers

假装没事ソ 提交于 2019-12-11 02:22:29
问题 Lets say I have a route like this: [Route("/users/{Id}", "DELETE")] public class DeleteUser { public Guid Id { get; set; } } If I am using CORS with a custom header, an OPTIONS preflight request will be sent out. This will happen on all requests. With the above route, the route will fire, but the OPTIONS will 404 and the ajax error handler will fire. I could modify the route to be [Route("/users/{Id}", "DELETE OPTIONS")] but I would need to do this on every route I have . Is there a way to

.htaccess is not working by my desires with CakePHP

走远了吗. 提交于 2019-12-11 02:21:27
问题 There is /localhost/domains/localhost/myCakephpApp on web server. I can't do anything with folder structure, but I can edit .htaccess in /localhost/, which now simplified looks like this: RewriteRule (.*) /domains/localhost/$1 [L] My website in localhost/domains/localhost/myCakephpApp has standard cake .htaccess file: RewriteRule ^$ app/webroot/ [L] RewriteRule (.*) app/webroot/$1 [L] It is nice that http://localhost/whatever/ works, but all links in cakephp (done with html helper) are

Is it possible in laravel 5 to show a pretty url to the user, and a practical url to the app?

女生的网名这么多〃 提交于 2019-12-11 02:12:26
问题 I have this url: mywebsite.com/user/1/edit I want my users to see this: mywebsite.com/edit-your-profile/ Is this possible when using Route::resource('user', 'UserController'); ? If yes, how do I do it :) ? I still want my app to be able to see user/1/edit as I use it in my middleware to prevent unauthorized access: if ( \Auth::user()->id != $request->segment(2) ) { return redirect()->back(); } So, one pretty url for my user, a practical one for my app. 回答1: Based on your explanation, I take

How to accept hash parameters in routes

拥有回忆 提交于 2019-12-11 02:10:52
问题 Query: I have a link like <%= link_to "link_name", :controller => "some_controller", :action => "some_action", :id => "some_id", :first_param => {:second_param => "some value"} %> and in my routes.rb map.connect '/some_name/:id' :controller => "some_controller", :action => "some_action" Above code is giving me a URL like http://localhost:3000/some_name/some_id my requirement is to construct the URL as: http://localhost:3000/some_name/some_id/value_inside_params[:first_param][:second_param]

ASP.NET MVC Hierarchy Url Routing

廉价感情. 提交于 2019-12-11 02:09:30
问题 I have a problem My route have an extra paramater after hierarchical category. /2009/World/Asia/08/12/bla-bla-bla asp.net mvc does not support this because my routing should be {year}/{*category}/{month}/{day}/{name} i tried use constraint like year = @"(\d{4})",category = @"((.+)/)+", month = @"(\d{2})", day = @"(\d{2})" but i cannot find any solution. Is there any comment? Thank you 回答1: I'm pretty sure that the route handler tokenizes on the slash character so you won't be able to have a