ASP.NET route to mvc or api by subdomain

后端 未结 2 1829
遇见更好的自我
遇见更好的自我 2020-12-17 07:38

Our application have 2 domains (www | api).mydomain.com

How can I route requests to api.mydomain.com to api controllers and www to mvc controllers?

Thank you

2条回答
  •  轮回少年
    2020-12-17 08:05

    Here is a blog post that aims at doing just what you are talking about. Essentially, the idea is to define the sub-domain in the routes you define:

    http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx

    However, the easiest and most obvious approach is to simply create two different sites. Since, one is your website and one is your API it make sense to seperate them into different projects.

提交回复
热议问题