Reputation: 101
In my asp mvc application, I have an CustomRoute which inherited RouteBase (this class is used for handle sub domain url)
public class CustomRoute : RouteBase
{
public override RouteData GetRouteData(HttpContextBase httpContext)
{
// do something
}
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
{
// do something
}
}
My RegisterRoutes method in Global.asax.cs file:
public static void RegisterRoutes(RouteCollection routes)
{
routes.IgnoreRoute("{resource}.axd/{*pathInfo}");
routes.Add(new CustomRoute());
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);
}
My goal is to handle all of url which contain sub domain base on CustomRoute, for another url will use asp mvc default route. HOW TO? any help would be greatly appreciated
Other problem is: all of resource (action / css / image....) which contain sub domain or not, it absolutely process by CustomRoute first :-(
Thanks for reading to the end :-)
Upvotes: 0
Views: 251
Reputation: 39413
You can add your resources to the IgnoreRoute
list
routes.IgnoreRoute("/Content/CSS/{*pathInfo}");
routes.IgnoreRoute("/Content/Images/{*pathInfo}");
Upvotes: 1