routing

ASP.NET MVC - absolute URL to content to be determines from outside controller or view

北慕城南 提交于 2019-12-05 18:12:30
I have some content which is sitting in a path something like this: /Areas/MyUsefulApplication/Content/_awesome_template_bro/Images/MyImage.png Is there a way get a fully qualified absolute URL to that path without being in a controller or view (where url helpers are readily available). You could write an extension method: public static class UrlExtensions { public static Uri GetBaseUrl(this UrlHelper url) { var uri = new Uri( url.RequestContext.HttpContext.Request.Url, url.RequestContext.HttpContext.Request.RawUrl ); var builder = new UriBuilder(uri) { Path = url.RequestContext.HttpContext

Route value with dashes

一曲冷凌霜 提交于 2019-12-05 18:06:45
I have this route: routes.MapRoute( "News", "News/{id}-{alias}", new { controller = "News", action = "Show" }, new { id = @"^[0-9]+$" }, namespaces: new[] { "Site.Controllers" } ); This route working for url's like this: http://localhost:54010/News/6-news But not working for url's like this: http://localhost:54010/News/6-nice-news How use dashes in my route value "alias"? EDITED Route like this: "News/{id}_{alias}" works for both url's: http://localhost:54010/News/6_news http://localhost:54010/News/6_nice-news The problem is with your pattern: News/{id}-{alias} because the Routeing is parsing

PHP Silex routing localization

℡╲_俬逩灬. 提交于 2019-12-05 17:55:22
starting with Silex. Say I want a localised site where all routes have to start with /{_locale} and don't fancy repeating myself as : $app->match('/{_locale}/foo', function() use ($app) { return $app['twig']->render('foo.twig'); }) ->assert('_locale', implode('|', $app['languages.available'])) ->value('_locale', $app['locale.default']) ->bind('foo'); $app->match('/{_locale}/bar', function() use ($app) { return $app['twig']->render('bar.twig'); }) ->assert('_locale', implode('|', $app['languages.available'])) ->value('_locale', $app['locale.default']) ->bind('bar'); Ideally, I'd like to create

Routing requests that end in “.cshtml” to a controller

隐身守侯 提交于 2019-12-05 15:10:19
(This is cross-posted to the ASP.NET forms) I'm working on the WebGit .NET project, and we are close to a "1.0" release. However, I'm having trouble getting my "Browse" controller (which pulls files out of the repository) to serve-up ".cshtml" files. I originally had trouble with ".config" and ".cs" files as well, but I fixed that with this in the web.config: <location path="browse"> <system.webServer> <security> <requestFiltering> <fileExtensions allowUnlisted="true"> <clear /> </fileExtensions> <hiddenSegments> <clear /> </hiddenSegments> </requestFiltering> </security> </system.webServer> <

Depth-first nested routing in an ASP.NET website

旧街凉风 提交于 2019-12-05 15:07:01
I've been exploring the System.Web.Routing namespace, playing with constraints and such, but I can't see a way to implement this. I'm working on an ASP.NET website ( non-WAP, non-MVC ) using the WebPages/Razor framework. I'm trying to implement a form of "nested routing", where a route can contain child routes that are only attempted if the parent matches; each child attempting to match the "remainder" of the URI. A "depth-first" route match search, if you will. routes.Add(new ParentRoute("{foo}/{*remainder}", new[] { new ParentRoute("{bar}/{*remainder}", new[] { new Route("{baz}"), new Route(

ASP.NET MVC One Way Route

梦想的初衷 提交于 2019-12-05 15:04:36
Is it possible to define a route in the RouteCollection of Asp.net MVC, so that it just does the "URL rewriting" part and ignore the URL generation with Html.Actionlink(...)? In fact I want to add a keyword between controller and action (controller/..keyword.../action) for certain very special requests. The generated URLs on the pages, however, should remain using the default routes. (controller/action) Yes you can do what you are asking. You would just create your own route that inherited from the current one and override GetVirtualPath to always return null. This way no Action lookup would

How-to: Devise after_sign_up_redirect?

南笙酒味 提交于 2019-12-05 14:31:19
I tried to follow the instructions here ( GitHub Devise Wiki ) but it's not working for me. I'm trying to get Devise to redirect to /welcome after user signs up. I created a Registrations controller but it's never going into the view. What am I doing wrong here? Ruby 1.9.2 Rails 3.1.0.rc4 Devise 1.4.2 Thank you UPDATE: For some reason after_sign_up_path_for is not triggered but after_sign_in_path_for is triggered. I would still like to get after_sign_up_path_for to work though _app/controllers/registrations_controller.rb_ class RegistrationsController < Devise::RegistrationsController

I18n in EmberJS (routing and in general)

无人久伴 提交于 2019-12-05 13:22:50
Does EmberJS support translated routes for internationalized apps? Or does it at least make it easy to extend it to support i18n routes? Anybody with experience with this? E.g. can the route string be somehow set dynamically from locale files? Also it would be cool when using Ember with Rails routing would not have to be specified twice... is that so? I'm new to Ember (currently evaluating js frameworks) but I assume in general with Rails one would simply specify very basic routes from within Rails and the rest in Ember? So there wouldn't be much duplication? Wonder if locale files from Rails

Route all requests through PageController except existing controllers (Zend Framework)

亡梦爱人 提交于 2019-12-05 12:46:38
For a new CMS i've developed a Pages module that allows me to manage the site's tree structure. Each page is reachable from the url http://www.example.com/pageslug/ where pageslug identifies the page being called. What I want to achieve now is a route that allows me to route all incoming requests to a single PagesController unless it's a request to an existing controller (like images for example). It's easy enough to catch all requests to the Pages Controller but how to exclude existing controllers? This is my module bootstrap. How can i achieve this in the most preferrable way <?php class

Rails - Failing Routes in deployment

本秂侑毒 提交于 2019-12-05 12:18:54
I have an app that has the following in the routes file: namespace "admin" do # ADMINISTRATIVE ROUTES ONLY root :to => 'home#index' resources :comments do member do get :approve get :reject end end resources :users do member do get :block get :unblock end end end When browing to /admin locally, I am greeted by the appropriate page. On the same URL on the heroku version I get a 404. The route shows correctly in 'heroku rake routes' Logs are showing: ActionController::RoutingError (wrong constant name Admin/ homeController): /disk1/home/slugs/196384_c95a9e3_4463/mnt/.bundle/gems/gems/