url-routing

How can I implement vanity URL's in a Rails application?

左心房为你撑大大i 提交于 2019-11-27 01:41:10
问题 I want users to able to have a profile page at site.com/myNameHere. Rails looks for a controller named "myNameHere." Is it possible to setup routes.rb so that if the controller is not found, "myNameHere" gets sent as a parameter to another controller? 回答1: You can add a route like this: map.profile_link '/:username', :controller => 'profiles', :action => 'show' Be sure to add it low enough in the file, below your resources, that it doesn't interfere with other routes. It should be lowest

Auto-versioning in ASP.NET MVC for CSS / JS Files?

怎甘沉沦 提交于 2019-11-27 00:30:56
问题 I have read lots of article on how to auto-version your CSS/JS files - but none of these really provide an elegant way to do this in ASP.NET MVC. This link - How to force browser to reload cached CSS/JS files? - provides a solution for Apache - but I'm a little confused how this could be implemented via ASP.NET MVC ? Would anyone be able to provide some advice how to do this on IIS7 and ASP.NET MVC - so that CSS/JS files automatically have a version number inserted in the URL without changing

.htaccess and seo-friendly urls

老子叫甜甜 提交于 2019-11-26 23:25:33
问题 We have an ecommerce site right now that carries a range of brands. The brand pages carry urls as follows: http://www.<DOMAIN>.com/catalog/brand/view?id=2 We need to utilize more friendly (seo-friendly) urls such as: http://www.<DOMAIN>.com/<BRAND> but such that it would resolve #1 above. Is this done in .htaccess files in the root? If so, what is the correct way to go about this? Keep in mind URL#1 is the legitimate address, but we want to utilize the URL#2 format for linking. It's not a 301

Rails routes with optional scope “:locale”

感情迁移 提交于 2019-11-26 23:20:44
问题 I'm working on a Rails 3.1 app and I'd like to set specific routes for the different languages the app is going to support. /es/countries /de/countries … For the default language ('en'), I don't want the locale to be displayed in the url. /countries Here is the route definition I've set. scope "(:locale)", :locale => /es|de/ do resources :countries end It works great, until I try to use a path helper with 'en' as the locale. In the console : app.countries_path(:locale => 'fr') => "/fr

How to get RouteData by URL?

醉酒当歌 提交于 2019-11-26 22:28:57
I need to get RoutData by given URL string in ASP.NET MVC application. I've found the way that I need to mock HttpContextBase based on my URL string and then pass it to RouteTable.Routes.GetRouteData() method in Route Parsing (Uri to Route) thread. How to mock HttpContextBase to retrieve RouteData by URL string using RouteTable.Routes.GetRouteData() ? Or is there another way to retrieve RouteData by URL? Serge S. I used Moq to determine what members of HttpContextBase are used in GetRouteData() . They are: Request AppRelativeCurrentExecutionFilePath PathInfo Request

Organize routes in Node.js

北慕城南 提交于 2019-11-26 22:28:51
问题 I start to look at Node.js. Also I'm using Express. And I have a question - how can I organize web application routes? All examples just put all this app.get/post/put() handlers in app.js and it works just fine. This is good but if I have something more than a simple HW Blog? Is it possible to do something like this: var app = express.createServer(); app.get( '/module-a/*', require('./module-a').urls ); app.get( '/module-b/*', require('./module-b').urls ); and // file: module-a.js urls.get('/

How to defer routes definition in Angular.js?

冷暖自知 提交于 2019-11-26 21:56:21
I have configured some basic routes that are available for all users before they log in: App.config(function ($routeProvider) { $routeProvider. when('/login', { templateUrl: 'views/login.html', controller: PageStartCtrl.Controller }). otherwise({ redirectTo: '/login' }); }); So the only thing user can do is to log in. After the user logs in, I would like to register additional routes like this: $http .post('api/Users/Login', { User: userName, Password: userPassword }) .success(function (response : any) { App.config(function ($routeProvider) { $routeProvider .when('/dashboard', { templateUrl:

Client Routing (using react-router) and Server-Side Routing

拈花ヽ惹草 提交于 2019-11-26 21:08:54
I have been thinking and I am confused with the routing between Client and Server. Suppose I use ReactJS for server-side rendering before sending the request back to web browser, and use react-router as a client-side routing to switch between pages without refreshing as SPA. What comes to mind is: How are the routes interpreted? For example, a request from Home page ( /home ) to Posts page ( /posts ) Where does the routing go, on server-side or client? How does it know how it is processed? Note, this answer covers React Router version 0.13.x - the upcoming version 1.0 looks like it will have

Mvc area routing?

萝らか妹 提交于 2019-11-26 20:58:01
问题 Area folders look like : Areas Admin Controllers UserController BranchController AdminHomeController Project directories look like : Controller UserController GetAllUsers area route registration public override void RegisterArea(AreaRegistrationContext context) { context.MapRoute( "Admin_default", "Admin/{controller}/{action}/{id}", new { action = "Index", id = UrlParameter.Optional }, new { controller = "Branch|AdminHome|User" } ); } project route registration public static void

Can angularjs routes have default parameter values?

我与影子孤独终老i 提交于 2019-11-26 20:32:15
问题 Can I set a default value of a parameter of a route in AngularJS? Is there a way to have /products/123 and /products/ handled by the same route ? I'm looking to refactor my existing code, which looks like: myModule.config(['$routeProvider', function($routeProvider) { $routeProvider. when('/products/', {templateUrl: 'products.html', controller: ProductsCtrl}). when('/products/:productId', {templateUrl: 'products.html', controller: ProductsCtrl}) }]); function ProductsCtrl($scope, $routeParams)