Skip to content

Getting subdomain value from route values

Mariusz Kerl edited this page Dec 8, 2017 · 1 revision

So now we know how to set our subdomain route and catch its value in controller. What about getting that value from our route values? Our application thinks tenant is just another route value. We can use it in filters, views etc. For displaying our subdomain value we could write below code in our cshtml file.

@ViewContext.RouteData.Values["tenant"]

When url is http://mycompany.localhost:54575 then mycompany would be displayed.

Clone this wiki locally