<location> 路径属性必须是相对虚拟路径:位置以“.”开头。

<location> path attribute must be a relative virtual path: Location starts with "."

我需要为以“.”开头的位置设置自定义 web.config 设置:

<location path=".somepath">

不幸的是,ASP.NET 似乎不喜欢以句号开头的路径。我收到以下错误:

Configuration Error: <location> path attribute must be a relative virtual path. It cannot start with any of ' ' '.' '/' or '\'.

有什么解决方法吗?

事实证明有一个非常简单的解决方案:将 web.config 文件放在以“.”开头的实际目录中。因此,我没有将根 web.config 与 <location path=".somepath"> 一起使用,而是在“.somepath”目录中创建了一个 web.config 文件并在其中添加了配置。如果“.somepath”是一个文件,我不确定我会做什么。

路径可以以“~/”开头:

<location path="~/.somepath">