title: Get domain and subdomain in MVC .net Core
body: <p>How should I get the current domain and subdomain in MVC .net core2 in Startup.cs. I managed to do it in MVC3 and 4 but I cannot find anything in the documentation related to this. My startup file looks like this: <br /></p>
  
  <pre><code>public class Startup
  {
      public Startup(IConfiguration configuration)
      {
          Configuration = configuration;
      }
  
      public IConfiguration Configuration { get; }
  
      // This method gets called by the runtime. Use this method to add services to the container.
      public void ConfigureServices(IServiceCollection services)
      {
          services.AddMvc();
      }
  
      // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
      public void Configure(IApplicationBuilder app, IHostingEnvironment env)
      {
          if (env.IsDevelopment())
          {
              app.UseDeveloperExceptionPage();
              app.UseBrowserLink();
          }
          else
          {
              app.UseExceptionHandler("/Home/Error");
          }
  
          app.UseStaticFiles();
  
          string subdomain = //subdomain should come here
          string domain = //domain should come here
  
          app.UseMvc(route =&gt; CustomRouting.GetRouts(route,domain,subdomain));
  
      }
  </code></pre>