我们在尝试读取配置文件中的连接字符串时出现错误。这是我如何阅读配置文件:无法读取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