routing

How do I route images using ASP.Net MVC routing?

I upgraded my site to use ASP.Net MVC from traditional ASP.Net webforms. I'm using the MVC routing to redirect requests for old .aspx pages to their new Controller/Action equivalent: routes.MapRoute( "OldPage", "oldpage.aspx", new { controller = "NewController", action = "NewAction", id = "" }...

Using ASP.NET routing to serve static files

Can ASP.Net routing (not MVC) be used to serve static files? Say I want to route http://domain.tld/static/picture.jpg to http://domain.tld/a/b/c/picture.jpg and I want to do it dynamically in the sense that the rewritten URL is computed on the fly. I cannot set up a static route once and for all. Anyway, I can create a route like...

How do I create userfriendly urls like stackoverflow?

I want to create a similar type of url as stack overflow does when a question is created. Example: http://stackoverflow.com/questions/1149454/non-ajax-get-post-using-jquery-plugin I am particularly interested in the last part which I have highlighed in bold. How do you achieve the affect of adding the title of the page to the url with...

Removing null/empty keys from a query string in asp.net MVC

Is there a way I can remove null or empty keys from a query string in asp.net MVC? For example I have a page where I filter data on a results table, if I search for John the query string would be redisplayed as: candidates?FirstName=John&LastName=&Credit=false&Previous=false&Education=&Progress= and not candidates?FirstName=John I ...

Rails nested resource issue

I have a couple of resources, a grant_application, and a household which are related with a has_one class GrantApplication < ActiveRecord::Base has_one :household, :dependent => :destroy end class Household < ActiveRecord::Base belongs_to :grant_application end ..and I also use the following route.. map.resources :grant_applica...

Form is posting to wrong URL

Original title: Can't fixed misconfigured routes I want to make a search based in a filter (with 4 possibles values) and a criteria entered by the user. I have the following routes: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.MapRoute( "SubLineasProductosDefault", "SubLineas...

Rails routing and URI fragment identifier

When I was developing my RoR skills with some basic tutorials I encountered a problem. What I am trying to achieve is having comments belonging to posts, with no separate index or individual view. This part was easy. Here comes tough one. I want post_comment_url to return address with fragment identifier: http://example.com/posts/2#comm...

ASP.Net MVC Routing - using same pattern for different controllers

Say I have an ASP.Net MVC site with products and categories, and I want these urls... Products: Fruitshop.com/super-tasty-apple Fruitshop.com/squishy-orange Fruitshop.com/worm-infested-apple Fruitshop.com/megaorange Categories: Fruitshop.com/apples Fruitshop.com/oranges For each product/category in the database, I save the slug ...

How does asp.net mvc figure it out?

How is it that I can create a method in the controller and just put some arguments and it figures it out after I click on a form submit? Under the hood, how does it find the right method and how does it figure out that I just want those arguments? ...

ASP.NET MVC routing - trying to have a name in the url

hi all, I have currently the following routes: routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.IgnoreRoute("{resource}.gif/{*pathInfo}"); MvcRoute.MappUrl("{controller}/{action}/{ID}") .WithDefaults(new { controller = "home", action = "index", ID = 0 }) .WithConstraints(new { controller...

Should rails ajax calls be bundled into their own separate controller?

Should AJAX calls that are not RESTful be: put in the controller that most suits their functionality/view, or bundled together into their own separate 'Ajax' controller? I've been doing 1, but I've just read this (2725 diggs) article http://zygote.egg-co.com/10-dirty-little-web-development-tricks/ (see point 9) and this chap opts f...

ASP.NET MVC, Url Routing: Maximum Path (URL) Length

The Scenario I have an application where we took the good old query string URL structure: ?x=1&y=2&z=3&a=4&b=5&c=6 and changed it into a path structure: /x/1/y/2/z/3/a/4/b/5/c/6 We're using ASP.NET MVC and (naturally) ASP.NET routing. The Problem The problem is that our parameters are dynamic, and there is (theoretically) no lim...

New Action Not Working

I have a standard User controller with the normal set of actions (index, show, new, edit, etc) and I'm trying to add a new action named 'profile'. I added the following code: def profile @user = User.find(session[:user_id]) end I also created a new view for the action (app/views/users/profile.html.erb), but whenever I try to view...

asp.net mvc custom routes with multiple submit buttons

So I have a custom route as such: routes.MapRoute( "Wizard", // Route name "Wizard/{page}", // URL with parameters new { controller = "Wizard", action = "Index" } // Parameter defaults ); and have the following on my View: <% Html.BeginForm("Continue", "Wizard"); %> <input type="submit" value="Continue"...

What would be an ASP.NET MVC route to a static Sitemap.xml?

If I want my url to look like, www.mysite.com/sitemap.xml, how would my route look in my Global.asax file? What is the simplest way for me to route and return that static Sitemap.xml file? ...

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

Hi, 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:/...

Rails nested routing to html id

given a blog style application: #models class Post < ActiveRecord::Base has_many :comments end class Comment < ActiveRecord::Base belongs_to :post end #routes.rb map.resources :posts do |posts| posts.resources :comments end how do I generate routes to an id on a page? Examples /posts/1#comments /posts/2#comment14 ...

301 Redirect after a route is matched but before controller execution

I'd like to add a trailing slash to any url's that match a valid route but do not currently end in a slash, i.e. www.example.com/url After a url is matched to a valid route I would like to 301 redirect to the same url but add the trailing slash i.e. www.example.com/url/ I've spent some time looking into it but I can't seem to figure it...

Route Chaining with the Zend Framework

I'm trying to implement route chaining for an admin panel on a Zend Framework site that I am working on. I'm using the following configuration file in hopes that the "admin" route routes with "/admin" and that the "adminLogin" route routes with "/admin/login". <?xml version="1.0" encoding="UTF-8"?> <routes> <admin> <route>admi...

how can I find out the current route in rails?

I need to know the current route in a filter in rails.. how can I find out? I'm doing REST resources, and no named routes ...