我們在嘗試讀取配置文件中的連接字符串時出現錯誤。這是我如何閱讀配置文件:無法讀取web.config文件
ConfigurationManager.ConnectionStrings[connectionStringName];
以下是錯誤。 虛擬路徑'/ site1'映射到另一個應用程序,這是不允許的。
最後,這是我在IIS服務器上的網站結構。請注意,三個子網站託管在主網站下。
注意:該錯誤並不總是發生。有時候所有的網站都可以正常工作,沒有任何問題這三個子網站也是指相同的代碼庫。
下面是完整的跟蹤日誌:
The following exception was thrown: The virtual path '/site1' maps to another application, which is not allowed.. Exception details: System.ArgumentException: The virtual path '/site1' maps to another application, which is not allowed.
at System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp)
at System.Web.HttpContext.GetFilePathData()
at System.Web.HttpContext.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.GetSection(String sectionName)
at System.Configuration.ConfigurationManager.get_ConnectionStrings()
我似乎已經在下面的場所,也是這個問題:
The following exception was thrown: The virtual path '/site1' maps to another application, which is not allowed.. Exception details: System.ArgumentException: The virtual path '/site1' maps to another application, which is not allowed.
at System.Web.CachedPathData.GetVirtualPathData(VirtualPath virtualPath, Boolean permitPathsOutsideApp)
at System.Web.HttpContext.GetFilePathData()
at System.Web.HttpContext.GetSection(String sectionName)
at System.ServiceModel.Activation.HostedAspNetEnvironment.UnsafeGetSectionFromWebConfigurationManager(String sectionPath, String virtualPath)
at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetSectionNoTrace(String sectionPath)
at System.ServiceModel.Diagnostics.TraceUtility.SetEtwProviderId()
at System.ServiceModel.ChannelFactory..ctor()
at System.ServiceModel.ChannelFactory`1..ctor(Type channelType)
at System.ServiceModel.ChannelFactory`1..ctor(Binding binding, EndpointAddress remoteAddress)
at System.ServiceModel.ClientBase`1..ctor(Binding binding, EndpointAddress remoteAddress)
這似乎當系統嘗試讀取網頁出現服務設置。
從哪個站點嘗試讀取配置? –
對於所有三個網站I.m得到相同的錯誤 – user1659922
你可以在web.config文件中顯示我們,並在IIS屏幕截圖中展開其中一個Web應用程序。 – Craig