routing

Zend Framework, mapping the extension of a URL to the format parameter?

与世无争的帅哥 提交于 2019-12-23 12:23:42
问题 It is possible to map the extension of a URL, to the format parameter in ZF? I'd like the default routing to still work, including mapping parameters from the URI, so you'd be able to say: http://example.com/controller/action/param1/value1/param2/value2.json Here: $this->_getParam('format') => "json" And likewise: http://example.com/module/controller/action/param1/value1/param2/value2.xml Here: $this->_getParam('format') => "xml" I've fiddled with the default routes, but i cannot get it to

One controller for multiple routes

半城伤御伤魂 提交于 2019-12-23 12:18:08
问题 I've been searching for a while now, but I can't seem to figure out if this is even possible. What I need is one controller for two different paths. What I have is one model, with two types: own and compatitive. So what I want is two paths like this, going both to one controller: example.com/hotels example.com/compatitives These have to be resources, and there is going to be a lot of nesting in these routes. So I don't want to create a resource mapping for both of them. I've already tried

Sammy routing not working

◇◆丶佛笑我妖孽 提交于 2019-12-23 11:00:41
问题 I'm unable to get sammy.js routing working as expected. I have the following JavaScript. (function ($) { var app = $.sammy('#main', function () { this.get('#/', function (context) { context.log("start page"); }); this.get("#/another/:id/", function (context) { context.log("another page with id = " + context.params["id"]); }); }); $(function (context) { app.run('#/'); }); })(jQuery); My understanding is that whenever the URL has changes, and so long as the new route corresponds to one of the

ASP.NET MVC page/subpage routing

﹥>﹥吖頭↗ 提交于 2019-12-23 10:59:09
问题 I'm try to figure out how to handle the following scenario. In general, i have a bunch of records in a table. All of these have ID and ParentID fields to form a tree. Page1 - Page2 - Page3 Page4 - Page5 -- Page6 Now, i want my routes for Page3 and Page6 to be like /Page1/Page6 and /Page3/Page5/Page6 respectivelly. That is, i want to include all parents in the URL. How to set my controller action/routing to achieve the above result? Edit: Forgot to mention that the above structure will be

Play Framework 2.2.1 - Case insensitive routing

我与影子孤独终老i 提交于 2019-12-23 09:37:53
问题 I am novice to the Play and currently working Play 2.2.1 I am trying to acheive case insensitive routing for my endpoints which are defined in "routes" e.g. I have define an route say /accessLicense in routes file, it would look like below GET /accessLicense controller.MyController.accessLicense() Now, if I fire /accessLicense it woks great; as expected, but if try to fir /AccessLicense, /AcCeSSLicenSe or any other combination of upper/lower case letter which spell exact same word, it doesn't

ASP.NET (MVC) routes internationalization

廉价感情. 提交于 2019-12-23 09:19:59
问题 I was looking for a solution to internationalize/localize routes on an ASP.NET MVC website. I stumbled upon the blog post Translating routes (ASP.NET MVC and Webforms) by Maarten Balliauw. He present a very nice solution, which works great - until there's a Html.RenderAction("...") in the view. Basically he introduces a TranslatedRoute inheriting from System.Web.Routing.Route , that than does the translation using a Dictionary with the translations on the fly. Any idea why this behaves

Check url before redirect symfony2

我与影子孤独终老i 提交于 2019-12-23 09:05:52
问题 if ($u = $this->generateUrl('_'.$specific.'_thanks')) return $this->redirect($u); else return $this->redirect($this->generateUrl('_thanks')); I wan't to redirect to the _specific_thanks url when it exist. So How to check if a url exist? When I did that, I had this error: Route "_specific_thanks" does not exist. 回答1: I don't think there's a direct way to check if a route exists. But you can look for route existence through the router service. $router = $this->container->get('router'); You can

ASP.NET Web Api returns 200 OK when it should return 404

*爱你&永不变心* 提交于 2019-12-23 08:51:02
问题 I have the following action methods on a controller in an ASP.NET Web API project: [Route("api/v2/project/{projectId}/stuff"), HttpGet] public IHttpActionResult Get(int projectId) [Route("api/v2/project/{projectId}/stuff/{id:guid}"), HttpGet] public IHttpActionResult Get(int projectId, [FromUri] Guid id) [Route("api/v2/project/{projectId}/stuff"), HttpPost] public IHttpActionResult Post(int projectId, [Required] Stuff stuff) [Route("api/v2/project/{projectId}/stuff/{id:guid}"), HttpPut]

ASP.Net MVC: Passing a string parameter to an action using RedirectToAction()

血红的双手。 提交于 2019-12-23 08:04:15
问题 I would like to know how to pass a string parameter using RedirectToAction(). Let's say I have this route: routes.MapRoute( "MyRoute", "SomeController/SomeAction/{id}/{MyString}", new { controller = "SomeController", action = "SomeAction", id = 0, MyString = UrlParameter.Optional } ); And in SomeController, I have an action doing a redirection as follows: return RedirectToAction( "SomeAction", new { id = 23, MyString = someString } ); I tried this redirection with someString = "!@#$%?&* 1"

Angular 2 RC5 : No provider for Router

丶灬走出姿态 提交于 2019-12-23 07:51:48
问题 I am facing an issue using the new Angular 2 RC5 router (router version is RC1). Here is the log I get from the dev console: EXCEPTION: Error in /templates/app.component.html:2:0 ORIGINAL EXCEPTION: No provider for Router! Here is what my app.modules.ts looks like: import { NgModule } from '@angular/core'; import { BrowserModule } from '@angular/platform-browser'; import { FormsModule } from '@angular/forms'; import { HttpModule } from '@angular/http'; import { RouterModule } from '@angular