ASp.Net MVC Default Route
I have my default route defined like this routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ...
I have my default route defined like this routes.MapRoute( "Default", // Route name "{controller}/{action}/{id}", // URL with parameters new { controller = "Home", action = "Index", id = "" } // Parameter defaults ...
I'm working on an ASP.NET MVC task list and I'd like to get fancy with the URL routing when filtering the list. I have an action method defined like this: public ActionResult List(int categoryID, bool showCompleted, TaskFilter filter); enum TaskFilter { MyTasks, MyDepartmentTasks, AllTasks } I want my URLs to look like this: /Tasks/...
I'm deploying a MCV 1.0 project on a web server running IIS6. (not by my choice) I've thru Steve Sandersons article Here and Phil Haack's article but I'm still having probelms. Right now I'm trying to implement Option 2 from Steve Sandersons article. The main problem I'm having is with the Home link not rendering correctly. For Instanc...
How can I get the controller name of a relative Url, using the routes I have defined in Global.asax? Example: if I have a route defiend like this: routes.MapRoute( "Default", // Route name "{language}/{controller}/{action}/{id}", // URL with ...
Given a url that follows the following pattern: firstcolor={value1}/secondcolor={value2} where value1 and value2 can vary and an action method like: ProcessColors(string color1, string color2) in say a controller called ColorController. I want the following route evaluation: URL '/firstcolor=red' results in a call like ProcessColor...
Could someone explain how routes are associated with controllers in MVC 2? Currently, I have a controller in /Controllers/HomeController.cs and a view /Home/Index.aspx. My route registration method looks like this: public static void RegisterRoutes(RouteCollection routes) { routes.IgnoreRoute("{resource}.axd/{*path...
I have a custom HttpModule rewrite engine in an existing web application project that maps urls of the form /tom/dick/harry/.../.../... to a hierarchical navigation system stored in a database, ultimately resulting in a HttpContext.Current.RewritePath() call to the .aspx page that the requested path resolves to. I'm interested in mixi...
Hello is it possible to have an ASP.NET MVC form that uses the routes defined in Global.asax to post its values (via a GET request)? I have the form defined like this: <% using (Html.BeginForm("CanviaOpcions","Sat",FormMethod.Get)) { %> <fieldset> <legend>Opciones</legend> <%= Html.DropDownList("nomSat")%> ...
I have a routing rule routes.MapRoute( "Search", // Route name "Restaurant/AdvancedSearch/{foodType}", // URL with parameters new { controller = "Restaurant", action = "AdvancedSearch", foodType = "" } // Parameter defaults ...
I'm trying to create a catch-all route to track when an affiliate string is in the URL. An affilite code is marked by an x followed by an int, and will only appear at the end of a URL (but before the query string). The idea is that I will extract the affiliate ID, do some logging, then do a 301 to the same request without the affiliate ...
I have the following two routes defined in my MVC app.;- At the moment I have two "MVC View content pages" defined /ShowName/NameById /ShowName/Index However the content on these two pages are identical? Is it possible for two routes to share the same content page? If not then can I a) create a single rule for both routes or b) should...
I'm using MVC 2 Preview2, with two areas in a single project. When I use RouteTable.Routes.GetVirtualPath(this.viewContext.RequestContext, null) from inside an area, I got the virtual path to the first area instead. Except for this, areas are working pretty well. What can I doing wrong? ...
I noticed that in MVC 2 Preview 2, AreaRegistration is loading the routes for each area in an arbitrary order. Is there a good way to get one before the other? For example, I have two areas - "Site" and "Admin". Both have a "Blog" controller. I would like the following: /admin/ --> go to Admin's Blog controller / --> go to Site...
Url.Action is a great mechanism to generate URL's as you can think in terms of controllers, actions, and parameters instead of hard-coded URL's. However it's not going to work when you use a catchall parameter in your route. What would be a recommended approach to generate URL's for a route that is using a catchall? ...
I am moving from an old site design to a new design with new URL's. All previous page names were static files called PageXX.html, PageX.html, Index.html - where X is a number. My site is now dynamic but I want to trap for those 3 incoming url's and then try and redirect to a certain new page (301 Redirect) else send them to the home pa...
I need a set up a website that accepts URLs from an older web site version and permenantly redirect them to the new site. I tried this code from Phil Haack's blog but it seems to redirect everything and severely screw up all route generations. http://haacked.com/archive/2008/12/15/redirect-routes-and-other-fun-with-routing-and-lambdas....
I am developing an international web site - multiple countries, multiple languages. I am trying to create SEO friendly URLs. For example the catalog consists of cartesian product Regions x Categories. A typical catalog url has 7 levels of hierarchy: www.site.com/en/Catalog/Browse/10/28/London/Category1 The route format is as follows: ...
Is there any way to force a Route to be executed, only if all tokens are present in the URL string? Consider this Route: RouteTable.Routes.MapRoute( "Default", "{controller}/{action}/{id}", new { controller = "Test", action = "Index", id = 0 } ); This Route execute on /Home/Index/1 and /Hom...
Is there any way to get truly restful routing working in MVC, just like the rails dudes have? I 'm talking about nested urls like /bands/metallica/albums/killemall/track/4 The only library that I found to be useful is Steve Hodgkiss' Restful routing. It seems though a bit risky to base my whole project's routing on this guy's pet-projec...
When implementing error-handling using the built-in validation-helpers on a strongly-typed view, you usually create a try/catch block within the controller and return a view with it's corresponding model as a parameter to the View() method: The controller public class MessageController : Controller { [AcceptVerbs(HttpVerbs.Post)] ...