Can One IIS WebSite host multiple Web Applications of different ASP.NET versions?

后端 未结 5 1916
谎友^
谎友^ 2020-12-19 17:59

I have one web site in IIS, and I would like to have version 2, 3.5, and 4 applications hosted under the same IIS web site. Is this possible?

Thought it\'d be as ea

相关标签:
5条回答
  • 2020-12-19 18:42

    You need separate IIS Applications for each web app. Coincidentally, separate apps can have separate App Pools, which in turn can have separate .NET framework versions.

    But that's not your issue

    In the case of your app, you're having issues with a .NET 2.0 web app and a .NET 3.5 web app, which use the same version of .NET (CLR 2.0). The issue you're seeing is because the sub-app isn't marked as a separate application, so the runtime is looking in the wrong place for the assembly to load your type.

    Your site contents probably look something like this:

    root (~/)
    - bin
      * app.dll
    - sub-app
      - bin
        * subapp.dll
    

    When the subapp runs, it's trying to load type Second.Namespa._Default, but the assembly path is to ~/bin (root/bin), which doesn't contain the correct assembly. If you mark sub-app as its own application in IIS, you'll get this:

    root (~/)
    - bin
      * app.dll
    - sub-app (~/ again for anything below)
      - bin
        * subapp.dll
    

    Now loading Second.Namespa._Default will look in the ~/bin (now sub-app/bin), and find the correct assembly and be able to load the type.

    0 讨论(0)
  • 2020-12-19 18:46

    You can have multiple applications hosted by one website on one IIS. Do the following:

    1.) Add a website to your IIS

    2.) Go to the physical folders on your harddisk/ftp-server and define the folders, where your applications should live inside the website, for example: [ ] = folder ( ) = file

    =====>[root]

    ==========>(web.config)

    ==========>[bin]

    ==========>[sites]

    ==========>[images]

    ==========>[application 1]

    ====================>(web.config) (to clear and overwrite inherited settings)

    ====================>[bin]

    ====================>[sites]

    ====================>[images]

    ==========>[application 2]

    ====================>(web.config) (to clear and overwrite inherited settings)

    ====================>[bin]

    ====================>[sites]

    ====================>[images]

    3.) Go back to the IIS Manager and choose "Application Pools" and "Add a new application pool". Call it "application 1". Repeat it and call the second "application 2"

    4.) Choose your website on the left and browse through the folders, that you have just created. Right click on folder "application 1" and choose "convert into application". Do the same for folder "application 2". Each time you do that, choose the application pool from step 3.)

    5.) You are ready. Now, when you put code in the "bin" folder of "application 1" or "application 2" it is seen as a different and seperat application.

    6.) Be aware, that all web.config properties from folders above "application 1 or 2" are inherited. You can overwrite them by using your own web.config inside the folder "application 1 or 2", using the "clear" tag or the "remove" and "add" tag. Chances are high, that you have definded a web.config for the root folder of your website. This web.config will be inherited by your applications.

    0 讨论(0)
  • 2020-12-19 18:48

    Be sure to choose and configure a seprate app pool for the second site/application.

    0 讨论(0)
  • 2020-12-19 18:49

    Can you post more details about the error?...

    Yes...you can do it...you can create an "Application" within a website in IIS ...and this application can use a totally different application pool and can target a different .NET framweork...

    0 讨论(0)
  • 2020-12-19 18:57

    You can host all the versions of .NET in one single IIS provided you separate the sites into Application Pools. Within the App Pool each application is run by the same .NET version (set on the pool)

    0 讨论(0)
提交回复
热议问题