I have an asp.net mvc web application for a large scale application which is multi lingual supporting 15 different languages. I am using attribute routing to localize my routes as there is a requirement to localize the url's. This creates 2675 routes.
I use Html.ActionLink and Url.Action helper methods to generate url's to my controller actions. I have found though including these in my Partial Razor Views to slow down the rendering of my views. For example, if I remove some of them, the response time can from 5-6 seconds to under a second.
I believe the issue may be around the large number of routes. Therefore I believe optimization of this is required.
Has anyone have had this problem with routing with a large number of routes in conjunction with Attribute Routing? Any caching or similar that can be included to assist? I don't mean output caching, but caching of the routes to ensure Html.ActionLink and Url.Action render quicker?
Edit
With attribute routing, I have added route prefix attribute to my controllers and also attribute to my actions. Following is a sample of a class. I don't explicitly add routes anywhere that I am aware of - I am presuming that its attribute routing is doing so
[RoutePrefix("customer", TranslationKey = "customer")]
public partial class CustomerController : BaseController
{
[Route("logon", TranslationKey = "logon")]
public virtual ActionResult LogOn(string returnUrl = "")
{
...
}
[GET("changerepresentative/{id:long}")]
public virtual ActionResult ChangeRepresentative(long id)
{
...
}
[GET("profile", TranslationKey = "profile")]
public virtual ActionResult ProfileInformation()
{
...
}
// etc
}
Configuration for attribute routing
RouteTable.Routes.MapAttributeRoutes(config =>
{
var translationProvider = this.routeTranslationProvider.GetProvider();
config.AddRoutesFromAssemblyOf<MvcApplication>();
config.AddTranslationProvider(translationProvider);
config.AppendTrailingSlash = true;
config.UseLowercaseRoutes = true;
config.InheritActionsFromBaseController = true;
config.AutoGenerateRouteNames = true;
config.RouteNameBuilder = RouteNameBuilders.FirstInWins;
});