A
A
Anatoly Shirokov2014-12-18 15:02:07
ASP.NET
Anatoly Shirokov, 2014-12-18 15:02:07

Asp.net mvc 4/5 create subdomain?

Good day everyone!
Guys, tell me how you can create a subdomain in c # mvc.
In the application, for example, there is an Admin area, when accessing this area, it is necessary that the Url be admin.localhost - using the example of local IIS
Set it in etc / hosts:
127.0.0.1 admin.localhost found the AttributeRouting
library , everything is simple and clear! I spent the night on parsing - but it didn’t work out, apparently I missed something . If anyone implemented this functionality, please describe it step by step.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
N
Nikolai Molchanov, 2014-12-19
@kroniak

It is necessary to write your own routing, on the basis of which the url will be parsed when accessed, unless of course they (subdomains) look at the same IIS.
But, it is better to do either several projects or work with zones.
stackoverflow.com/questions/278668/is-it-possible-...

V
Vladimir Dementiev, 2015-10-27
@SayMAN83

Here I already posted a fully working solution. it remains only to transfer the user to a personal subdomain during authorization. Also, the domain name should be "mydomain.com", not "mydomain". Otherwise, you will spend a lot of extra time fighting cross-domain authorization problems.
Converting to work in areas is a matter of changing a couple of lines of code. The code was originally made under areas, duplicating in each routing file. But when trying to transfer the code to the main routing file for universality, it accidentally turned out to get rid of the areas altogether and choose your own subdomain according to any criterion (be it a login or a group of users).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question