routing

In ASP.NET MVC 2 - How do I get Route Values into my navigation controller so I can highlight the current link?

南楼画角 提交于 2019-12-03 21:32:26
问题 I'm trying to get the current Route into my navigation controller so I can run comparisons as the navigation menu data is populated. My Links object is like this: public class StreamNavLinks { public string Text { get; set; } public RouteValueDictionary RouteValues { get; set; } public bool IsSelected { get; set; } } In the master page, I'm trying to pass the current route to the nav controller like this: <% Html.RenderAction( "MenuOfStreamEntries", // action "Nav", // controller new { //

How do I route in Flask based on the domain of the requested URL?

那年仲夏 提交于 2019-12-03 21:25:23
I'm trying to implement routing based on the host of the requested URL for a Flask site I'm building. Based on what I've read here and elsewhere , it seems like this should be possible with something like from flask import Flask application = Flask(__name__) application.url_map.host_matching = True @application.route("/", host="<prefix>.mydomain.com:<port>") def mydomain(prefix='', port=0, **kwargs): return 'This is My Domain: with prefix ' + prefix @application.route("/", host="<prefix>.<project>elasticbeanstalk.com:<port>") def test(prefix='', project='', port=0, **kwargs): return 'You are

CodeIgniter dynamic URI routing possible?

核能气质少年 提交于 2019-12-03 21:15:06
My application is designed to provide a single profile page for each user, with the 3rd segment being the user's ID. example.com/profile/page/1 Assuming user 1 is "Jon Jovi", using CI's routing I would like to generate this URI example.com/jon_jovi Is it possible to send this user's ID to config/routes.php , run a function to extract user 1's info from database and insert it like $route['profile/page/$row->id'] = $row->first_name . '_' . $row->last_name; Any thought or suggestions on how to do this are much appreciated - thanks. If you want to the "client" url to be in format base_url/

How bad is ip fragmentation

梦想与她 提交于 2019-12-03 21:00:10
I understand that when sending ip messages around, each hop in the network path between be and my packet's destination will check if the next hop's MTU is bigger than the size of the packet I sent. If so, the packet will be fragmented and the two packets will be separately sent to the next hop, only to be reassembled at destination (or, in some cases, at the first NAT router encountered). As far as I understand, this thing can be pretty bad, but I don't really understand why. I understand that if the connection tends to drop a lot of packets, losing a single fragment means I have to resend the

:except not working in before_filter in application controller. Routing problem?

拟墨画扇 提交于 2019-12-03 20:46:34
问题 I have a before_filter in my application controller to keep a user's session alive (and log them out if a time out has been reached). This should be called on every action except /sessions/new and /sessions/destroy which are routed as /login and /logout. The relevant parts of my application controller look like this; class ApplicationController < ActionController::Base before_filter :update_activity_time, :except => [:login, :logout] private def update_activity_time if current_user time_out =

Routing with action after id parameter in Web API

冷暖自知 提交于 2019-12-03 20:35:40
In web api the default route is: /api/locations/123?days=5 config.Routes.MapHttpRoute( name: "DefaultApi", routeTemplate: "api/{controller}/{id}", defaults: new { id = RouteParameter.Optional } ); But what if I wanted the route to look like this /api/locations/123/events?days=5 while still being able to hit the LocationsController with a route like this /api/locations/123?state=md Controller: public class LocationsController : ApiController { // GET api/locations/123/events?days=5 public IEnumerable<Event> GetEventsByDays(int idLocation, int days) { // do stuff } // GET api/locations/123?state

How to pass params to a block in Rails routes?

*爱你&永不变心* 提交于 2019-12-03 20:28:37
I am using Rails 3. And I'm wondering how to pass params to some blocks in routes.rb . What I'm trying to do is to make a catch all route, that check from slugs database the model name of it by the id. After getting the model name i pluralize it to get the controller name. match '/:id', :controller => proc { Slug.find_by_iid(params[:id]).model.pluralize }, :action => :show The table slugs model iid ----- ----- post 4d2c7de0c5abe7f8a9000007 item 4d2c7de0c5abe7f809000004 When I try to access some pages like /4d2c7de0c5abe7f8a9000007 I got this error: Started GET "/4d2c7de0c5abe7f8a9000007" for

How to route and render (dispatch) from a model in Ruby on Rails 3

跟風遠走 提交于 2019-12-03 20:21:18
问题 I want to dispatch (route and render) from a model. (I only care about GET requests and I ignore Accept: headers, so I only look at PATH_INFO .) # app/models/response.rb class Response < ActiveRecord::Base # col :path_info # col :app_version # col :body, :type => :text def set_body params = Rails.application.routes.recognize_path(path_info, :method => :get) controller = "#{params[:controller].camelcase}Controller".constantize.new controller.action_name = params[:action] controller.request =

Heroku cedar, Rails 3.1rc6, subdomain routing

纵然是瞬间 提交于 2019-12-03 20:17:53
Locally, on Unicorn, my subdomain setup works fine. I've followed the heroku subdomain docs to the letter, and also the subdomains Railscast . subdomain.lvh.me:3000 points to the right place, and lvh.me:3000 points correctly to the root defined in routes.rb: root :to => "pages#home" However, in my new staging deployment on Heroku's Cedar stack, again using Unicorn, whilst subdomain.mydomain.co.uk points to the right place, mydomain.co.uk doesn't. Instead of going to pages#home as per the routes file, it's hitting the books controller, which it's only meant to do if there's a subdomain in the

How to handle non-root URLs in a singlepage app?

风流意气都作罢 提交于 2019-12-03 19:36:52
问题 I try to make a single page app with Rails 3.2 and Backbone.js with pushState option but faced with something that I do not understand. If I load the root URL of the app (/), everything goes right: Rails return an HTML-layout with JS which bootstraps Backbone which makes some XHRs for JSON-entities and renders the content. But if I start using app from non-root URL (e.g. by manually typing it in the browser's address bar) then Rails will try to handle this request using theirs routing rules