Reputation: 96
i am going to create some sub-domains on my website. when i create a sub-domain i must define a directory that sub-domain will refer to newly created sub-domain. but i want a different solution.
i want to detect when a user enters a URL , which sub-domain is used and then do some operation for each special sub-domain. for example if website user entered a.mysite.com i extract "a" sub-domain from URL and then without redirecting webpage i load some data in page.
please help me how i do these,on both web-server and localhost?
Upvotes: 1
Views: 246
Reputation: 2127
In general your application doesn't care about the host name, so you have to configure your IIS to handle all requests.
After this you can check the HttpContext.Current.Request.Url
and extract the requested subdomain.
Upvotes: 1