Reputation: 2005
To understand the code behind the AttributeRoutingConfig I'm trying to recreate it using RouteConfig
AttributeRoutingConfig.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Routing;
using AttributeRouting.Web.Mvc;
[assembly: WebActivator.PreApplicationStartMethod(typeof(SimplestAuth.AttributeRoutingConfig), "Start")]
namespace xyz
{
public static class AttributeRoutingConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.MapAttributeRoutes();
}
public static void Start()
{
RegisterRoutes(RouteTable.Routes);
}
}
}
RoutingConfig.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Web.Routing;
namespace xyz
{
public class RouteConfig
{
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "login", id = UrlParameter.Optional }
);
}
}
}
I'm looking for information to understand the differences and similarities between the two techniques. Thank you.
Upvotes: 0
Views: 315
Reputation: 10839
They both do essentially the same thing:
They register your routes to the RouteTable.
Hope that helps.
Upvotes: 1