Skip to content
Simple usage lib for subdomain routing in ASP.NET Core/Framework MVC
C# Other
  1. C# 99.0%
  2. Other 1.0%
Branch: master
Clone or download

Latest commit


Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode Constraints as a parameter Jun 27, 2018
src v1.1.0 release notes Jul 2, 2018
.gitignore Ignoring .vs directory Aug 1, 2017
LICENSE Initial commit Aug 1, 2017



ASP.NET Subdomain Routing

Goal of that lib is to make subdomain routing easy to use in asp net core mvc applications. Normally you would use some custom route for some special case scenario in your app. This should solve most of issues while using subdomain routing. Inspired by couple of already existing libraries around the web which handle routing in some degree this should meet requirements:

  1. Register subdomain routes as you would do with normal routes.
  2. Make links, forms urls etc. in views as you would do with helpers in your cshtml pages.
  3. Catch all route values in controller.

Continuous Integration

Build server Build status Unit tests Integration tests Functional tests
AppVeyor Build status Build status Build status Build status




Your application have to be aware of using subdomains. Important thing is to use method AddSubdomains() before AddMvc()

public void ConfigureServices(IServiceCollection services)
    // Add framework services.

You configure your routes just like standard routes, but you cannot use standard MapRoute methods. That will be explained later in wiki. Use MapRoute method from this lib extensions method which accepts hostnames as a parameter.

public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    var hostnames = new[] { "localhost:54575" };
    app.UseMvc(routes =>
            new { controller = "SomeController" });

            "{controller}", //that's subdomain parameter, it can be anything
            new { controller = "Home", action = "Action1" });


Your .cshtml files

Goal of that library is not only catching routes for subdomain but also generating links to actions while persisting standard razor syntax. Helper below will generate url <a href="http://home.localhost:54575">Hyperlink example</a>. Route named SubdomainRoute should catch that link.

@Html.ActionLink("Hyperlink example", "Action1", "Home")


Big advantage of library is you can catch all route values with controller.

public IActionResult Action1()

Having url http://home.localhost:54575/ will invoke Action1 method in Home controller.

Running samples project

You can’t perform that action at this time.