如何通过IIS服务器在2个不同的端口上运行相同的ASP.NET 3.5网站 [英] How to I run same ASP.NET 3.5 website on 2 different ports via IIS server
问题描述
我使用asp.net 3.5开发了一个员工离职跟踪网站,我在公司内部网上通过IIS 7.0服务器进行托管。
i已经在同一台服务器上为两个单独的部门部署了两次网站所以他们有相同的IP地址,但没有9696&其他在港口号9797
现在的问题是,两个网站共享cookie,我无法使用相同的浏览器同时登录这两个网站。
如果应用程序cookie在同一台服务器上托管但总共位于不同的端口,是否无法将其与其他网站分开。
什么我试过了:
尝试重命名两个网站中的cookie,只有在单独的浏览器中打开应用程序
Cookie不是特定于端口的。
有人建议在2000年的中添加此功能RFC 2695 [ ^ ];但是在2011年被 RFC 6265 取代[ ^ ],它没有提及port =
属性。 AFAIK,没有浏览器支持Set-Cookie2
标题或端口属性。
最接近的等价物是安全标志,表示只应使用HTTPS请求发送cookie。但是,没有设置此标志的cookie仍会针对HTTP和HTTPS请求发送,因此无法解决您的问题。
您有三种选择:
- 重命名cookie (仅在网站的一个版本上!)
你需要确保更新每一次使用,包括会话和身份验证的内置设置。- 将两个版本放在不同的路径上,并添加cookie的路径
所以你将http:// yourserver:9696 / path1 /
和http:// yourserver:9797 / path2 /
。
同样,您需要让每个cookie都使用正确的路径。- 为每个版本提供不同的主机名称
在指向服务器的内部DNS上设置两个A
记录,并在IIS中设置主机头,以便每个版本都响应一条记录。
例如:http://app1.yourserver.local/
和http: //app2.yourserver.loca升
I have developed a employee leave tracking website using asp.net 3.5 which i am hosting through IIS 7.0 server on my company intranet.
i have deployed the website twice for two seperate departments on same server so they have same ip address but port no 9696 & other on port no 9797
Now the issue is that both website share cookies and i cannot login into both the website at the same time using the same browser.
Is there no way to keep the application cookies seperated from other website if they are hosted on same server but different port altogether.
What I have tried:
tried renaming the cookies in the both the websites only thing that works is opening the app in a seperate browser
Cookies are not port-specific.
There was a suggestion to add this feature back in 2000 in RFC 2695[^]; but that was replaced in 2011 by RFC 6265[^], which makes no mention of theport=
attribute. AFAIK, no browser ever supported theSet-Cookie2
header or the port attribute.
The closest equivalent is the "Secure" flag, which indicates that the cookie should only be sent with HTTPS requests. But cookies without this flag set will still be sent for both HTTP and HTTPS requests, so it won't solve your problem.
You have three options:
- Rename the cookies (on one version of the site only!)
You'll need to make sure you update every single usage, including the built-in settings for session and authentication.- Put both versions on different paths, and add the path to the cookie
So you'll havehttp://yourserver:9696/path1/
andhttp://yourserver:9797/path2/
.
Again, you'll need to get every single cookie to use the correct path.- Give each version a different host name
Set up twoA
records on your internal DNS pointing to the server, and set up the host headers in IIS so that each version responds to a single record.
Eg:http://app1.yourserver.local/
andhttp://app2.yourserver.local
这篇关于如何通过IIS服务器在2个不同的端口上运行相同的ASP.NET 3.5网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!