Problems hosting multiple ASP.Net MVC3 applications in an IIS7.5 website

痞子三分冷 提交于 2019-12-23 23:05:06

问题


Some specs:

  • IIS 7.5
  • ASP.Net MVC3

I have three MVC3 applications I would like to host:

  1. Project A
  2. Project B
  3. Project C

I want to get the URLs to be like this, respectively:

  1. http://domain/
  2. http://domain/ProjectB
  3. http://domain/ProjectC

So in IIS, I have the default website, which points to the folder for ProjectA. I then added two Applications to it, one pointing to ProjectB, and one to ProjectC, and their respective folders on the hard drive. I am storing the sites in C:\sites. Each project has a folder in C:\sites where the application's files reside. As you can see, the sites are not nested at all on the server.

When I load http://domain/ProjectB, it is trying to load configuration values from the ProjectA web.config. Obviously this is not what I want, and I'm not that awesome at server configuration. I got it working by wrapping most of the ProjectA web.config in a location tag like so:

<location path="." inheritInChildApplications="false" >
    <!-- Lots of web.config stuff for ProjectA -->
</location>

I'm not really a fan of this, it feels wrong. To me, it seems like a nested Application in my site in IIS should not even know about the parent site. What am I doing wrong? I'm sure it is something really small. I would have made ProjectA an Application, but I don't want the alias on it, as I want http://domain/ to pull it up for the users.

Again, I am not that knowledgeable about server stuff, it just isn't fun to me, hence why I'm asking y'all!

Thanks!


回答1:


That is how it works. By default, asp.net applications inherit their parents web.config, and you either need to override those values in your lower web.config or wrap it in an inheritInChildApplications="false" attribute like you did above.

One possible option is if you can make your home page at the root of the site NOT an asp.net application. If you can't, you're stuck doing this.




回答2:


on goDaddy you can create iis virtual directories with "set application root", which then makes each director with "set application root" set act as a root directory (just as you want). The user don't notice anything. So you could look and see if you have that option?



来源:https://stackoverflow.com/questions/10521059/problems-hosting-multiple-asp-net-mvc3-applications-in-an-iis7-5-website

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!