1

我试图弄清楚 asp.net 应用程序如何从配置文件 appSettings 键设置 MasterPageFile,如下所示:

<appSettings>
  <add key="MasterPageFile" value="~/Other.Master" >
</appSettings>

这会导致它忽略 .aspx 文件(指向不同的母版页)中的 Page 指令的 MasterPageFile 属性。我搜索了整个解决方案,但找不到任何正在加载此 appSettings 键的 ConfigurationManager 或 MasterPageFile 调用。据我了解,您通常必须将其放在具有 masterPageFile 属性的 pages 元素中的配置文件的 system.web 部分中。

无论如何,如何从这个 appSettings 键设置母版页?还有其他方法可以检索我不知道的 appSettings 吗?

4

1 回答 1

0

MaserPage 文件可以设置在页面级别或 pre_init 级别。在配置级别设置它会覆盖您的页面设置,因此请避免使用它。

于 2012-11-30T03:40:58.550 回答