簡體   English   中英

在IIS中將bin綁定為虛擬目錄會創建global.asax錯誤

[英]Binding bin as a virtual directory in IIS creates global.asax error

我想將ASP.NET MVC應用程序部署到IIS服務器,並通過虛擬目錄導入其所有必需的資源。 這與應用程序中使用的所有其他文件夾都可以正常工作。 除了bin /文件夾。 如果我嘗試虛擬目錄的BIN文件夾,則該應用程序無法啟動:

Parser Error

Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately. 

Parser Error Message: Could not load type 'MyCompany.Services.Global'.

Source Error: 


Line 1:  <%@ Application Codebehind="Global.asax.cs" Inherits="MyCompany.Services.Global" Language="C#" %>

Source File: /global.asax    Line: 1 

現在我為什么要這樣做:

我公司有以下情況:

我們有一個ASP.NET MVC網站解決方案。 它在我們的一台服務器上為2個客戶部署。 兩個客戶總是同時部署。 兩者使用相同的版本。 但是他們兩個都使用不同的配置文件。 (Web.config和root-config.js表示角度)。

結構會像這樣

c:\inetpub\wwwroot\
                    + curstomerA\
                            + bin\
                            + Scripts\
                            + Views\
                            + (...)
                            + web.config
                            + root-config.js
                    + curstomerA\
                            + bin\
                            + Scripts\
                            + Views\
                            + (...)
                            + web.config
                            + root-config.js

c:\\ inetpub \\ wwwroot \\ curstomerA \\和c:\\ inetpub \\ wwwroot \\ curstomerB \\都是在IIS中創建的自己的網站。 它們具有不同的應用程序池,並綁定到不同的子域:

c:\\ inetpub \\ wwwroot \\ curstomerA \\ => customerA.myCompany.com

c:\\ inetpub \\ wwwroot \\ curstomerB \\ => customerB.myCompany.com

所以我想做的是

c:\inetpub\wwwroot\
                    + curstomerA\
                            + bin\
                            + Scripts\
                            + Views\
                            + (...)
                            + web.config
                            + root-config.js
                    + curstomerA\
                            + <bin> as virtualDirectory onto c:\inetpub\wwwroot\curstomerA\bin\
                            + <Scripts> as virtualDirectory onto c:\inetpub\wwwroot\curstomerA\Scripts\
                            + <Views> as virtualDirectory onto c:\inetpub\wwwroot\curstomerA\Views\
                            + (...) [like above]
                            + web.config
                            + root-config.js

它不能是訪問權限問題; 在本地計算機上,我放寬了對文件夾的訪問權限,但仍然無法正常工作。

現在我的問題是:為什么這不適用於BIN文件夾? 為了使這項工作我需要做什么?

還是我只是誤解了虛擬目錄的用途? (注意:我已閱讀https://www.iis.net/learn/get-started/planning-your-iis-architecture/understanding-sites-applications-and-virtual-directories-on-iis

好,在我閱讀了HG Sandhagen指出的鏈接和相關鏈接之后

它不能按預期方式工作,因為IIS使用虛擬目錄將url與物理目錄進行匹配,但是Web應用程序在web.config所在的主文件夾下的bin文件夾中查找dll(在物理目錄中)。 可以在web.config中更改搜索路徑。指定程序集的位置,但是據我所知,這僅適用於子文件夾。

這似乎是不可能的,因為它似乎僅適用於子文件夾。 因此,我通過創建目錄結解決了我的問題。

因此bin文件夾現在正在使用此符號鏈接,而我使用的其他目錄是虛擬IIS目錄。

PS:我意識到現在這個stackoverflow主題的標題應該是這樣的問題格式:

“為什么不能在IIS中成功將'bin \\'綁定為虛擬目錄?”

我很抱歉 ;)

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM