MVC 3 Domain Routing

2019-09-14 23:06发布

问题:

I would like to know if the following is possible. I have a website called www.myweb.com. This website could be a directory of say football teams. The list of teams could be found here

www.myweb.com/home/teamlist

On selecting a team one would be take to

www.myweb.com/teams/teama or
www.myweb.com/teams/teamb etc

the content under the teams area would be related to them e.g.

www.myweb.com/teams/teama/fixtures
www.myweb.com/teams/teama/news

i have the above working but would like to know if it is even remotely possible to have a separate website for each team which still uses the current models, views and controllers e.g.

www.teama.com

would go to display the data from

www.myweb.com/teams/teama

where 'teams' is the controller and 'teama' is a parameter for a 'details' action. Also doing

www.teama.com/fixtures 
www.teama.com/news

would display the same stuff as

www.myweb.com/teams/teama/fixtures
www.myweb.com/teams/teama/news

many thanks and hope i have worded it ok.

Rudy

回答1:

I would consider using IIS URL Rewriting in that case.



回答2:

Have a look at MVC Domain Routing, I'm still researching it myself as I have a similar required as yourself but I think that should do what you need.

The following links might be handy:

ASP.Net MVC Domain Routing

Bolt on multi-tenancy in ASP.Net MVC Part I (link to Part II is on the page)