是否可以基于不同的端口为localhost创建子域?

时间:2020-02-11 14:37:39

标签: c# asp.net asp.net-mvc asp.net-core asp.net-web-api

我遇到了一种需要从一个本地应用程序向另一个本地应用程序共享cookie的情况。我想知道是否可以通过将应用程序的地址之一localhost:number设置为另一个localhost的子域来实现它?

谢谢。

1 个答案:

答案 0 :(得分:0)

如果使用端口,则它不是子域,而是其他域。

如果您确实需要在主机文件中设置一个子域

在Windows c:\windows\system32\drivers\etc\hosts

在Linux /etc/hosts

127.0.0.1    domain.test
127.0.0.1    subdomain.domain.test