B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
You will likely find these resources useful for routing issues:
Routes are processed top down, first match is route used. You'll probably need the ability to debug your routes:
The first rule that fits the URL is the one that gets used. Default rules should be last.
The most general default rule should be the very last.
There's a really interesting tool and video that you might want to check out:
the RouteDebug dll tool is discussed in the last twenty minutes*
of Phil Haack's video: http://videos.visitmix.com/MIX09/T44F,
"Ninja on Fire Black Belt Tips".
B-) Please help me by completing my school survey about computer programmers on my website. Thank you!!! Gerry Lowry +1 705-429-7550 wasaga beach, ontario, canada
Marked as answer by ricka6 on Oct 03, 2009 12:44 AM
cranialsurge
0 Points
2 Posts
Route to a single controller action
Oct 01, 2009 06:28 PM|LINK
How do I create a rule for all URLs to a specific View folder to go to the same controller action ... ?
For example any URL that ends in ~/Sections/ should go to ~/Sections/Index.
I've tried the following to no avail:-
routes.MapRoute(
"Sections", // Route name
"Sections/*", // URL with parameters
new { controller = "Sections", action = "Index"} // Parameter defaults
);
<div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">routes.MapRoute(</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> "Sections", // Route name</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> "Sections/*", // URL with parameters</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> new { controller = "Sections", action = "Index"} // Parameter defaults</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste"> );</div>ASP.NET MVC MVC Controller action controllers routetes
gerrylowry
All-Star
20515 Points
5713 Posts
Re: Route to a single controller action
Oct 01, 2009 07:11 PM|LINK
http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx
gerrylowry
All-Star
20515 Points
5713 Posts
Re: Route to a single controller action
Oct 01, 2009 07:16 PM|LINK
Resources:
You will likely find these resources useful for routing issues:
Routes are processed top down, first match is route used. You'll probably need the ability to debug your routes:
The first rule that fits the URL is the one that gets used. Default rules should be last.
The most general default rule should be the very last.
There's a really interesting tool and video that you might want to check out:
the RouteDebug dll tool is discussed in the last twenty minutes*
of Phil Haack's video: http://videos.visitmix.com/MIX09/T44F,
"Ninja on Fire Black Belt Tips".
* Watch the entire video, it's worth your time.
ASP.NET MVC documentation is at MSDN: Reference .
Routing is here:
http://msdn.microsoft.com/en-us/library/system.web.routing.aspx
http://msdn.microsoft.com/en-us/library/system.web.routing.routecollection.aspx
see also: http://weblogs.asp.net/rashid/archive/2009/04/03/asp-net-mvc-best-practices-part-2.aspx
http://www.asp.net/learn/mvc/tutorial-23-cs.aspx
for IgnoreRoute see:
http://msdn.microsoft.com/en-us/library/dd505203.aspx in
http://msdn.microsoft.com/en-us/library/system.web.mvc.routecollectionextensions.aspx.
bitmask
Contributor
6739 Points
1245 Posts
MVP
Re: Route to a single controller action
Oct 01, 2009 08:28 PM|LINK
You just need to use a parameter name with your catch-all:
<div style="BORDER-BOTTOM: black 1pt solid; BORDER-LEFT: black 1pt solid; BACKGROUND-COLOR: #d3d3bd; FONT-FAMILY: monospace; FONT-SIZE: 8pt; BORDER-TOP: black 1pt solid; BORDER-RIGHT: black 1pt solid" mce_style="font-family:monospace;font-size: 8pt;border:solid 1pt black; background-color: #d3d3bd;">routes.MapRoute("Sections",
"Sections/{*path}",
new { controller = "Section", action = "Index" });
</div>
http://www.OdeToCode.com/blogs/scott/
http://twitter.com/OdeToCode
cranialsurge
0 Points
2 Posts
Re: Route to a single controller action
Oct 01, 2009 08:41 PM|LINK
Thanks for all who pitched in ... I found exactly what i was looking for here .. http://stackoverflow.com/questions/1263635/route-all-controller-actions-to-a-single-method-then-display-a-view-according-to