routing

Customize MapHttpAttributeRoutes for Web Api Versioning

南楼画角 提交于 2019-12-04 13:34:01
问题 I am implementing Web API versioning as in Web API Versioning. My controllers are in 2 separate namespaces, and I've used a custom SelectController method to choose which version to use based on a a query parameter. e.g. http://myapi/api/values?version=1.0 This all works fine but some actions in the controllers use the Route attribute [Route("api/values/getNames")] public HttpResponseMessage Get() { ... } Which are mapped to the correct controller by default using config

Rails 4 i18n, how to translate routes where subdomain is used for the locale

落花浮王杯 提交于 2019-12-04 13:27:47
问题 I am using subdomains to determine the locale in a Rails 4 website. I have this working with a locale switcher exactly the way I want it but now I need to translate the routes and I'm not sure about the best way to proceed. I have looked the https://github.com/kwi/i18n_routing i18n routing gem but this doesn't work with subdomains, it seems to change the path by adding /locale which is not what I need. Other gems seem to be out of date with Rails 4. Edit Basically I want to be able to use the

Force 'www' in Rails3 hosted on Heroku without .htaccess

强颜欢笑 提交于 2019-12-04 12:54:07
I was wondering if there was a Rack alternative to forcing the 'www' in the URL since Heroku doesn't use .htaccess files. Maybe even a nice way to do it in routes? Thanks A quick Google search reveals this Rack middleware , which appears to do exactly what you want. In your ApplicationController, you can simply create a before filter: before_filter :force_www! protected def force_www! if Rails.env.production? and request.host[0..3] != "www." redirect_to "#{request.protocol}www.#{request.host_with_port}#{request.fullpath}", :status => 301 end end Or to go the other direction and remove www:

How to use Control.GetRouteUrl from a class in App_Code

非 Y 不嫁゛ 提交于 2019-12-04 12:43:29
问题 I'm using routing in asp.net web forms 4.0 with some success. In my pages I am using Page.GetRouteURL to generate routes like this. <a href = '<%=GetRouteUrl("MyRoute", new {MyFirstRouteValue = "ABC", MySecondRouteValue=123}) #>' >Link Text</a> This works perfectly well, but I have found that there are times when I need to have this functionality in a class in app_code. I could just manually build the route with String.Format, but that is kind of sloppy since it would duplicate the code in

On query parameters change, route is not updating

血红的双手。 提交于 2019-12-04 12:36:54
In my application, there are multiple links in which I have some links with the same route but with different query parameters . say, I have links like: .../deposits-withdrawals .../deposits-withdrawals?id=1 .../deposits-withdrawals?id=2&num=12321344 When I am in one of the above routes and native to the other route from above mentioned, the route is not changing. Not even any of the functions like ngOnInit or ngOnChanges being called.I have changed the parameters from queryParameters to matrixParameters but with no success. I have gone through many links and answers. But, none of them solved

Iron-router nested routes with multiple parameters

亡梦爱人 提交于 2019-12-04 12:26:04
I have two models: sites and articles . Each site can have multiple articles. I would like to view the article in the route like this: /siteName/articleFriendlyTitleUrl . At the moment I have helper method to make friendly urls like this: getFriendlyUrl = function(urlString){ urlString = urlString.toLowerCase(); urlString = str.replace(/[^a-z0-9\s]/gi, '').replace(/[_\s]/g, '-'); return urlString; } And my router.js file: this.route('showArticle', { path: '/article/:title'), layoutTemplate: 'artLayout', data: function(){ viewData = { title: Articles.findOne({title: this.params.title}), site:

404 pages and Lazy Loading in Angular2

只愿长相守 提交于 2019-12-04 12:04:31
I am unable to let my '404 pages' work using lazy loading modules. When I enter a random url in the browser I only see a blank page instead of my cool 404 page. Here is my routing config export const routes: Routes = [ { path: '', redirectTo: 'dashboard', pathMatch: 'full'}, { path: 'dashboard', loadChildren: 'app/dashboard/dashboard.module#DashboardModule'}, { path: 'buckets', loadChildren: 'app/buckets/buckets.module#BucketsModule'}, { path: '**', loadChildren: 'app/notfound/notfound.module#NotFoundModule'} ]; export const routing: ModuleWithProviders = RouterModule.forRoot(routes); When I

IronRouter authorisation controller

醉酒当歌 提交于 2019-12-04 12:04:13
问题 I'm wondering if anyone could demonstrate how to use a global 'before' action on a router controller class that handles user authentication and displays the appropriate route/template based on the result. My use case is to have an AppController that acts as an authentication firewall and blocks any child controller actions when a user is logged out. E.g. // Create a primary app controller stub with the auth firewall AppController = RouteController.extend({}); // Extend the AppController with

How to set default function in codeIgniter when I visit Class with non-existent route?

a 夏天 提交于 2019-12-04 11:45:12
The controller like this: class Abc extends CI_controller{ public function index(){...} public function f1(){...} } If url is http://host/app/Abc/index it get function index If url is http://host/app/Abc/f1 it get function f1 If url is http://host/app/Abc it get function index because it is default But if url is http://host/app/Abc/f2 it print 404 not found I expected that if url is http://host/app/Abc/f2 it can turn to index function. If can't do this,I want to add new function automatically,What should I do? EDIT I want to use it in just a specific class, can I edit global routing? How? Two

ASP.Net MVC Routing problem with jQuery AJAX

懵懂的女人 提交于 2019-12-04 11:39:26
My page is domain.com/home/details/1 In my jQuery AJAX call I have the following however when it makes that call its making a call to domain.com/home/details/home/getdata What can I do to get it to resolve properly? $(document).ready(function () { oTable = $('#example').dataTable({ "bServerSide": true, "sAjaxSource": "Home/GetData/", "bProcessing": true, "bPaginate": true, "sPaginationType": "full_numbers", "bFilter": true, "bAutoWidth": false, "fnServerData": function (sSource, aoData, fnCallback) { /* Add some extra data to the sender */ //aoData.push({ "filtervalue": $('#filtervalue').val()