在 2 个不同的项目/解决方案/应用程序上创建子域和共享身份验证
我正在尝试在 asp.net mvc 中创建一个带有子域的网站。但我不知道该怎么做。在 Visual Studio 中设置这一新解决方案时,最好为每个子域设置一个不同的项目还是一个项目?显然,这样做有一些直接的优势,例如将更新发布到一个子域而不触及其他子域。 这是规范:
1)我有很多应用程序,每个应用程序都有自己的子域,例如App1,App2,App3。用户将通过登录页面的主域登录,并且此身份验证将传递到应用程序。
2)我需要域来对用户进行身份验证并将身份验证传递给子域。该子域仅允许经过身份验证的用户访问。 ASP.NET 允许将身份验证传递到子域。我需要知道的是如何设置项目,以便子域知道身份验证是通过这种方式通过的。
3)我决定走子域路线。
http://App1.domain.com/ http://App12.domain.com/
4)我也在考虑可重用代码。有没有办法在三个不同的子域上共享母版页、用户控件等?
I am trying to create a website with subdomains in asp.net mvc. But I am not sure how to do this. When setting up this new solution in visual studio is it best to have a different project for each subdomain or have one project? There are obviously some immediate advantages to this such as publishing updates to one subdomain without touching the others.
Here is the specification:
1)I have many applications , each have their own subdomain, e.g. App1, App2, App3. The user will login through the Main domain with login page, and this authentication will be passed down to the applications.
2) I need the domain to authenticate the user and pass the authentication to the subdomain. The subdomain will only allow access to authenticated users. ASP.NET allows the authentication to be passed to subdomains. What I need to know is how to set the projects so that the subdomian knows that the authentication is being passed this way.
3) I've decided to go down the subdomain route.
http://App1.domain.com/
http://App12.domain.com/
4)I'm also thinking about reusable code. Is there any way to share masterpage,usercontrols etc over the three different subdomains?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
单独的 Web 应用程序,并在每个应用程序的 web.config 中将
domain
属性设置为顶级域:这样,当用户在其中一个应用程序上进行身份验证时,身份验证 cookie 将包含域属性及其将被发送到该域和子域中的其他应用程序,并且用户也将在其他应用程序上自动进行身份验证。
Separate web applications and in the web.config of each set the
domain
property to the top level domain:This way when a user authenticates on one of the applications, the authentication cookie will contain the domain property and it will be sent along to other applications in this domain and sub-domains and the user will be automatically authenticated on the other applications as well.
前几天想到了类似的情况。我找到了两个选项来进行“动态子域注册”
在情况 1 中,我会将 *.mydomain.com 转发到 Web 服务器 (IIS),并使用 IIS 管理 API 将 myuser.mydomain.com 重定向到物理路径,例如 www.mydomain.com/myuser /
在情况 2 中,我只需将 www.mydomain.com/myuser/* 重写为 myuser.mydomain.com/*
身份验证应该不是问题,我会使用过滤器或类似的东西。
Thought about a similar situation a few days ago. I found two options for doing the "on the fly subdomain registration"
In case 1 I'd forward *.mydomain.com to the webserver (IIS) in that case and use the IIS Administration API to redirect myuser.mydomain.com to the physical path such as www.mydomain.com/myuser/
In case 2 I'd simply rewrite www.mydomain.com/myuser/* to myuser.mydomain.com/*
Authentication should not be the problem, I would use the a Filter or something like that.