routing

Session is null in IRouteHandler.GetHttpHandler with Asp.net routing

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-01 05:29:16
I'm trying to get Session enabled in the GettHttpHandler method of my IRouteHandler classes but session is always null. Could someone tell me what I'm doing wrong? In global.asax I have RouteTable.Routes.Add("All", new Route("{*page}", new MyRouteHandler())); The MyRouteHandler class where Session is null looks like this: public class MyRouteHandler : IRouteHandler, IRequiresSessionState { public System.Web.IHttpHandler GetHttpHandler(RequestContext requestContext) { string test = HttpContext.Current.Session["test"].ToString(); return BuildManager.CreateInstanceFromVirtualPath("~/Page.aspx",

ASP.NET MVC Colon in URL

天大地大妈咪最大 提交于 2019-12-01 05:16:17
I've seen that IIS has a problem with letting colons into URLs. I also saw the suggestions others offered here . With the site I'm working on, I want to be able to pass titles of movies, books, etc., into my URL, colon included, like this: mysite.com/Movie/Bob:The Return This would be consumed by my MovieController , for example, as a string and used further down the line. I realize that a colon is not ideal. Does anyone have any other suggestions? As poor as it currently is, I'm doing a find-and-replace from all colons (:) to another character, then a backwards replace when I want to consume

How to map Home/Action/id to just action/id?

依然范特西╮ 提交于 2019-12-01 04:53:39
问题 At the moment I have just this route defined routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Home", action = "Index", id = "" } ); I want to map the /Home/Action1/id to just /Action1/id anybody knows how ? 回答1: You may have to be careful with a route like you're asking for because it may catch more than is intended. One workaround is to restrict that route by using constraints if possible. E.g. Check that id is numeric... routes.MapRoute("ActionRoute", "{action}/

Rails 3 routing: Avoiding Deep Nesting

Deadly 提交于 2019-12-01 04:44:32
Today I realised I'd gotten a little carried away with nested resources: resources :organisations do resources :studies do resources :settings end end The Rails guidelines (and my own thoughts) suggest that you shouldn't nest more than 1 level deep, so I refactored to this: resources :organisations do resources :studies end resources :studies do resources :settings end Does anyone know a cleaner / more concise way to declare the above routes? Google gave me a lot of Rails 2-specific stuff. Many thanks! You pretty much got it figured out and on the right track. It really depends on your domain.

How to define default date values in Symfony2 routes?

半腔热情 提交于 2019-12-01 04:37:05
问题 If I want to create a route, where the year, month and date are variables, how can I define that if these variables are empty, the current date shall be taken? E.g. like this (doesn't work for sure...) blog: path: /blog/{year}/{month}/{day} defaults: { _controller: AcmeBlogBundle:Blog:index, year: current_year, month: current_month day: current_day } I thought about defining two different routes, like this blog_current_day: path: /blog defaults: { _controller: AcmeBlogBundle:Blog:index } blog

Routing with express.js - Cannot GET Error

混江龙づ霸主 提交于 2019-12-01 04:21:37
问题 Working with express.js for the first time, and I am stuck on adding my first route. My route is defined in app.js like so: app.get('/user/:id/photos', function(req,res){ res.send('user' + req.params.id); }); However curling to http://localhost:3000/user/1/photos just results in a "cannot GET" error. The index file that was included with express seems to work just fine though. This is my express app.js file: var express = require('express'), routes = require('./routes'); var app = module

Rails reload dynamic routes on multiple instances/servers

空扰寡人 提交于 2019-12-01 04:12:28
问题 How can we force Rails to reload_routes on multiple servers/instances? We have a multi-tenant platform in Google App-Engine running on 5+ instances and we want all of our sites to define their own set of routes from the backend. Whenever we have a new site we currently have to restart all servers in order to be able to access the new routes. We followed this guide but it does only work on a local environment and is not updating routes on all servers in production without restarting the

Path parsing in rails

我的未来我决定 提交于 2019-12-01 04:12:00
问题 I am looking for method for parsing route path like this: ActionController::Routing.new("post_path").parse #=> {:controller => "posts", :action => "index"} It should be opposite to url_for Upd I've found out: What is the opposite of url_for in Rails? A function that takes a path and generates the interpreted route? ActionController::Routing::Routes.recognize_path("/posts") So now I need to convert posts_path into "/posts" 回答1: There's this method: >> ActionController::Routing::Routes

Rails RSpec Routing: Testing actions in :except do NOT route

六眼飞鱼酱① 提交于 2019-12-01 04:08:33
Fairly simple problem (I'd have thought), but I'm having some issues: In Rails 3.1.0.rc6/RSpec 2.6.0, I'm trying to test the routing of my 'products' resource, routed like this: resources :products, :except => [:edit, :update] The routing for the valid actions works, but I want to ensure that the edit and update routes are not callable. Here's what I'm trying: it "does not route to #edit" do lambda { get("/products/1/edit") }.should raise_error end Failure/Error: lambda { get("/products/1/edit") }.should raise_error expected Exception but nothing was raised # ./spec/routing/products_routing

CodeIgniter | .htaccess removing index.php from url

╄→гoц情女王★ 提交于 2019-12-01 04:07:29
ok, i did exactly as asked in the documentation of codeigniter, created new file .htaccess RewriteEngine on RewriteCond $1 !^(index\.php|images|robots\.txt) RewriteRule ^(.*)$ /index.php/$1 [L] i am using xampp, so my url for accessing the site was http://localhost:12/projects/zorkif_nextgen/index.php/main now after applying the above .htaccess file, i tried it without index.php like this http://localhost:12/projects/zorkif_nextgen/main but instead of working, it is redirecting me to this url http://localhost:12/xampp How to resolve this issue? plus i am getting error on my page after trying