且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

使用IIS7在同一IP地址上托管多个Web应用程序(asp.net)时出错

更新时间:2022-05-11 06:39:42

1. )使用两个单独的网站-
设置端口绑定的主机名,以便IIS可以通过分析请求URL来确定请求哪个网站(右键单击web-SITE并选择编辑绑定"
例如:
web-SITE1:绑定到主机名app1.example.com,端口:80
web-SITE2:绑定到主机名app2.example.com,端口:80

IIS然后将为您选择正确的网站.然后,您将无法仅使用IP地址访问Web-SITES,因为IIS需要HOSTHEADER(= IIS绑定中的主机名)来确定正确的Web-SITE.
2.)或者,您可以在一个网站下运行多个Web应用程序,只需右键单击该网站并选择添加应用程序" ...
例如:
网站:绑定到主机名app.example.com,端口:80
-别名为"app1"的web-Application1
-别名为"app2"的web-application2

客户端可以使用网址app.example.com/app1等访问app1.


不知道哪个更适合您的需求...


当您面对案例2)时,我假设您在web-SITE级别具有一个web.config,而在应用程序级别具有一个web.config.检查其中是否有具有相同名称的添加元素.
1.) using two seperated web-SITES:
set host name for port-bindings, so that IIS can determine which web-site is requested by analyzing the request URL (rightclick web-SITE and choose "edit bindings"
e.g.:
web-SITE1: binds to hostname app1.example.com, port:80
web-SITE2: binds to hostname app2.example.com, port:80

IIS will then chose the right web-SITE for you. You will then be unable to access your web-SITES using only the IP-Address, as IIS needs the HOSTHEADER (=host name in IIS bindings) to determine the right web-SITE.

2.) alternatively, you can run multiple web-APPLICATIONS under one web-SITE, just right-click on the web-SITE and choose "add Application"...
e.g.:
web-site: binds to hostname app.example.com, port:80
- web-Application1 with alias "app1"
- web-application2 with alias "app2"

Clients can access app1 using Url app.example.com/app1, etc.


don''t know which one fits better to your needs...


as you are facing case 2.), i asume that you have a web.config at web-SITE level and one on application-level. check, if there are add-Elements with the same name in it.