routing

Ending a Rails 2 URL with an IP address causes routing error?

爱⌒轻易说出口 提交于 2019-12-03 00:40:54
I'm trying to construct URLs in the format http://servername/find/by/CRITERION/VALUE CRITERION is a finite set of strings, as is VALUE. Trouble is, VALUE needs to be an IP address in some situations, and it's causing me a routing error. Here's my route: map.find 'find/by/:criterion/:query', :controller => "find", :action => "by" And the error, from the Mongrel logs: Processing ApplicationController#index (for 127.0.0.1 at 2010-05-07 10:20:32) [GET] ActionController::RoutingError (No route matches "/find/by/ip/1.2.3.4" with {:method=>:get}): Rendering rescues/layout (not_found) If I visit /find

ASP.net MVC site : Redirect all “non WWW” request to WWW

旧街凉风 提交于 2019-12-03 00:34:53
Recently I migrated an ASP.net site to ASP.net MVC site. Earlier there were two host headers one mydomain.com and another is www.mydomain.com. My SEO says you should use only one url "www.domain.com" for SEO advantage. I am looking for an option to do 301 permanent redirect all mydomain.com request to www.mydomain.com. The site is hosted in IIS6 and developed in ASP.net MVC 4. Craig Unfortunately, the URL rewrite module does not work with IIS6 (only IIS7 or greater). Have you considered creating your own HttpModule, something like this this? IIS 6 how to redirect from http://example.com/* to

Recursive routes in Rails

依然范特西╮ 提交于 2019-12-02 23:44:36
Is is possible to create a recursive route in Rails? I have an application, which allows a admin to create pages. The page model is a nested set and so each page has a parent_id hence the pages are structured in trees. The page model also uses the Friendly ID plugin to provide slugs for each page. When a user browses the site I would like them to see the nesting structure in the urls - its better for search engine purposes as well as any users who might like to browse the site by chopping the urls. I want something along the lines of: http://example.com/page/page/page/page ...etc Now obviously

Efficient vehicle routing for transfer of packages

試著忘記壹切 提交于 2019-12-02 22:59:36
问题 I have a warehouse and three distribution and receiving locations. I know the distances between each of them in relation to each other. Each location has a varying amount of standard size packages but of varying weight. I have three vehicles, one that carries 30 packages or 1100lbs, one that carries 20 packages or 700lbs, and one that carries 15 packages or 500lbs. I am trying to make a spreadsheet that can enter in the packages and their weights I have to send to each location and a how many

asp.net 4 routing not working in iis 7

帅比萌擦擦* 提交于 2019-12-02 22:47:45
I'm using asp.net 4 routing in one of our new product and it works fine in the development environment (Visual studio webserver). but when i moved it to remote iis for testing purpose it doesn't work. all i get is 404 error page. i tried adding the following to the web.config and still getting the error. <system.webServer> <modules runAllManagedModulesForAllRequests="true"> <add name="UrlRoutingModule" type="System.Web.Routing.UrlRoutingModule, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" /> </modules> <validation validateIntegratedModeConfiguration="false" />

internal/modules/cjs/loader.js:582 throw err

▼魔方 西西 提交于 2019-12-02 22:47:29
Recently I started learning Node.js with express. I have tried express router which threw an error. The bigger issue is what caused this and how can I avoid it again. This problem makes me worry and discourages me to learn node.js. Here is the error. What do I need to do? internal/modules/cjs/loader.js:582 throw err; ^ Error: Cannot find module 'C:\Users\User\Desktop\NodeJsProject\app.js' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15) at Function.Module._load (internal/modules/cjs/loader.js:506:25) at Function.Module.runMain (internal/modules/cjs/loader.js:741:12)

Multiple optional route parameters in Express?

廉价感情. 提交于 2019-12-02 21:52:51
I am using Express to handle a route which is in the format of /articles/:year/:month/:day , where year, month and day are optional. If none of the three params is given, all articles will be returned; If year is given, articles of that year will be returned; If year and month are given, articles of that year and month will be returned; If all three params are given, articles of that year, month and day will be returned. My question is, how do I make them optional? With the current route I've defined, unless all three parameters are present, it will not be able to be resolved and will fall

Laravel Pass Parameter from Route to Filter

旧街凉风 提交于 2019-12-02 21:51:06
I am using the laravel framework. If I have the following route: Route::get('/test/{param}', array('before'=>'test_filter', 'SomeController@anyAction')); And this filter: Route::filter('test_filter', function() { $param = [Get the parameter from the url]; return "The value is $param"; }); How can I pass parameters to the filter so that when visiting /test/foobar I would get a page saying: "The value is foobar"? Filters can be passed parameters, like the Route object or the Request: Specifying Filter Parameters Route::filter('age', function($route, $request, $value) { // }); Above example is

How do i construct a route without ViewContext in ASP.NET MVC?

﹥>﹥吖頭↗ 提交于 2019-12-02 21:13:22
I want to create a route from a utility class that doesn't have access to a ViewContext. Is this possible? There doesnt seem to be any equivalent of ViewContext.Current I've tried fishing around in all the constructors for Routing and HttpContext but can't quite get to what I want. This is what I'm looking for - although this doesn't work because RouteTable.Routes is of type RouteCollection and not RouteData . So close - yet so far :-) RequestContext requestContext = new RequestContext(HttpContext.Current, RouteTable.Routes); UrlHelper url = new UrlHelper(requestContext); var urlString = url

Removing Controller from url in a specific scenario

送分小仙女□ 提交于 2019-12-02 21:10:33
问题 I want to remove Controller named Home from url when user clicks on About and Contact pages in ASP.NET MVC sample application . I tried this but it is giving me a 404 error. routes.MapRoute("Home", "{action}/{id}", new { controller = "Home" }); When i remove this all works perfectly. Note I want to remove Controller name only when Controller is Home. Other Controller should remain same. Further I kept the code in Route.Config file above routes.MapRoute("Home", "{action}/{id}", new {