Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 16th, 2012  |  syntax: None  |  size: 0.95 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Nasty interaction between ASP.NET MVC Routing and my login system
  2. public class HomeController : Controller {
  3.     [CustomAuthorize] // My custom authorization tag
  4.     public ActionResult Index() {
  5.         // ...
  6.     }
  7. }
  8.        
  9. public class MvcApplication : HttpApplication {
  10.     public static void RegisterGlobalFilters(GlobalFilterCollection filters) {
  11.         filters.Add(new HandleErrorAttribute());
  12.     }
  13.  
  14.     public static void RegisterRoutes(RouteCollection routes) {
  15.         routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
  16.  
  17.         routes.MapRoute(
  18.             "Default", // Route name
  19.             "{controller}/{action}/{id}", // URL with parameters
  20.             new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
  21.         );
  22.     }
  23.  
  24.     private void Application_Start() {
  25.         AreaRegistration.RegisterAllAreas();
  26.  
  27.         RegisterGlobalFilters(GlobalFilters.Filters);
  28.         RegisterRoutes(RouteTable.Routes);
  29.     }
  30. }