custom-routes

Redirecting to a custom route in MVC

怎甘沉沦 提交于 2021-02-11 08:06:42
问题 I have setup a custom route in my MVC site. I am having trouble figuring out how to redirect to it though. Here is my custom route code: public class MemberUrlConstraint : IRouteConstraint { public bool Match(HttpContextBase httpContext, Route route, string parameterName, RouteValueDictionary values, RouteDirection routeDirection) { if (values[parameterName] != null) { var permalink = values[parameterName].ToString(); return string.Equals(permalink, Member.GetAuthenticatedMembersUrl(),

Url Routing for unknown number of params

China☆狼群 提交于 2020-01-06 14:07:35
问题 I have seen this post: MVC Handler for an unknown number of optional parameters but it's for MVC and doesn't seem to work for me as I get an error: A path segment that contains more than one section, such as a literal section or a parameter, cannot contain a catch-all parameter. I want to be able to have an indeterminate amount of params in a Url, I have the following route: RouteCollection.MapPageRoute("ManyParam", "{*params}.html", "~/Default.aspx"); This also seems to trigger the error

Rails 3.0.10, customer routes, post and form_for tag

孤街浪徒 提交于 2020-01-04 06:01:37
问题 I have this in my routes: resources :events do collection do post 'moderate' end end Rake routes tells me: moderate_events POST /events/moderate(.:format) {:controller=>"events", :action=>"moderate"} I have an "administration" controller that simply lists Events that need moderating: @modevents = Event.where('moderated <> 1') So far so good, all the events that haven't been moderated can be displayed in the view: <%- @modevents.each do |me| -%> Display Stuff here <%- end -%> I want to put a

How to replace “-” with “_” in url before mapping a controller and an action in a .net mvc3 application

眉间皱痕 提交于 2019-12-24 02:18:28
问题 Hello everyone :I am working on a .net mvc3 application. Here is my controller and action : public class Foo_Bar : Controller { public ViewResult Foo_Bar() { return View(); } } And my corespondent view file is : Foo_Bar.cshtml now ,my question is : I have a url as: www.mystite.com/foo-bar/foo-bar but this url can not invoke the Foo_Bar/Foo_Bar controller and action except I write it as thes: www.mystite.com/foo_bar/foo_bar . Now I need to replace the "-" with "_" before the route system

How to replace “-” with “_” in url before mapping a controller and an action in a .net mvc3 application

亡梦爱人 提交于 2019-12-24 02:18:01
问题 Hello everyone :I am working on a .net mvc3 application. Here is my controller and action : public class Foo_Bar : Controller { public ViewResult Foo_Bar() { return View(); } } And my corespondent view file is : Foo_Bar.cshtml now ,my question is : I have a url as: www.mystite.com/foo-bar/foo-bar but this url can not invoke the Foo_Bar/Foo_Bar controller and action except I write it as thes: www.mystite.com/foo_bar/foo_bar . Now I need to replace the "-" with "_" before the route system

Rails 3 routing with resources under an optional scope

别来无恙 提交于 2019-12-24 00:25:39
问题 I have setup my versioned API like this with only a small tweak for backwards compatibility. In my routes I have: scope '(api(/:version))', :module => :api, :version => /v\d+?/ do … scope '(categories/:category_id)', :category_id => /\d+/ do … resources :sounds … end end with the successful goal already reached of having the following URL's reach the same place /api/v1/categories/1/sounds/2 /api/categories/1/sounds/2 /categories/1/sounds/2 /sounds/2 My directory structure is like this: The

Rails3 Routes - Passing parameter to a member route

吃可爱长大的小学妹 提交于 2019-12-18 02:01:32
问题 I would like to pass an extra parameter to a member route of a resource something like: resources :events do member do get 'register/:participant_type_id' end end I could only accomplish it using a static match statement Looking around the internet I saw that this might be possible in Rails 3.0.2. I'm using 3.0.1 and it certanlly is not. Am I doing something wrong? or is it really not possible? thanks 回答1: Try this: resources :events do member do get 'register/:participant_type_id', :action =

action parameters routing not working in Zend framework routes.ini

不羁的心 提交于 2019-12-13 03:53:51
问题 I'm trying to set up a route in Zend Framework (version 1.11.11) in a routes.ini file, which would allow be to match the following url: my.domain.com/shop/add/123 to the ShopController and addAction . However, for some reason the parameter (the number at the end) is not being recognized by my action. The PHP error I'm getting is Warning: Missing argument 1 for ShopController::addAction(), called in... I know I could set this up using PHP code in the bootstrap, but I want to understand how to

Upgrade classic ASP to MVC 4.0

时间秒杀一切 提交于 2019-12-12 00:06:48
问题 I'm in the process of upgrading from classic ASP to MVC 4.0. MVC projects have a unique folder structure with modules, views, and controllers. Our classic ASP website is very well indexed in search engines, and uses all friendly URLs (some mapped to existing folders and removing page extensions, and others mapped for SEO and not to the folder containing the files), using Rewrite Rules in web.config. I need to maintain all the current URLs, but they all map into different folders than the MVC

MVC.NET Custom Root Handler Wrong action in Html:BeginForm

好久不见. 提交于 2019-12-11 19:33:11
问题 I used custom mvc route handler. But When I use Html.BeginForm or Ajax.BeginForm in the view, Action parameters change unexpectedly. My codes are above My Register Route method is : public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute("alias", "{alias}", defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults ).RouteHandler = new FriendlyUrlRoutehandler(); routes.MapRoute