Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: ASP.NET XML MVC
How to achieve ASP.NET MVC3 Routing(controller and Action methods) through XML File?
Posted 30-May-12 6:40am
vasumch809
Comments
stian.net at 12-Jul-12 8:41am
   
As i read your question you want to store all your routes in a xml-file?
If so: I think that is a bad idea! Why should you wanna do that? It is possible! Just read xml-file in tha same place as you would create routes (Application_Start) but your routes should be "hard-coded". Why? 1) You can see in your code that your ActionLink is correct or broken. 2) Links should not change often (due to search engines, bookmarkes etc)
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

These should give you an overview and get started:
Controllers and Routers in ASP.NET MVC 3[^]
Creating a Custom Route Constraint (C#)[^]
MVC: How to route /sitemap.xml to an ActionResult?[^]
MvcSiteMapProvider 3.0.0 for MVC3[^]
 
example:
routes.MapRoute(
            "Sitemap",
            "sitemap.xml",
            new { controller = "Home", action = "SiteMap" }
            );
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

in mvc routing you can write following code into globle.asax file
public class MvcApplication : System.Web.HttpApplication
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
 
routes.MapRoute(
"Login", // Route name
"{controller}/{action}/{id}", // URL with parameters
new { controller = "Login", action = "LoginPage", id = UrlParameter.Optional } // Parameter defaults
);
 
}
 
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();

 
RegisterRoutes(RouteTable.Routes);
}
}
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 OriginalGriff 410
1 Jochen Arndt 200
2 Richard MacCutchan 135
3 DamithSL 105
4 PIEBALDconsult 90
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,032
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,220


Advertise | Privacy | Mobile
Web03 | 2.8.141220.1 | Last Updated 12 Jul 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100