zoukankan      html  css  js  c++  java
  • 我没发现Mvc里的 web.config 有什么用。

    实验过程

    由于 Mvc2+ 引入 Area ,导致文件夹结构发生变化。 Mvc下的 web.config 所在的位置是:

    ~/Areas/MySystem/Views/Web.config

    对应的请求的URL是:

    ~/MySystem/Home/Index

    这时, 在根目录下添加 AppSetting 项:

        <add key="AdminUserId" value="LhlcAdministator"/>

    在 ~/Areas/MySystem/Views/Web.config 覆盖 根下的 AdminUserId

      <remove key="AdminUserId" />

        <add key="AdminUserId" value="Host"/>

    在 ~/MySystem/Home/Index 对应的Action 写如下代码:

      return Content( System.Configuration.ConfigurationManager.AppSettings["AdminUserId"].ToString() );

    结果

    期望的结果是: Host

    结果输出的是根Web.config配置结果: LhlcAdministator

    分析

    调试发现,把 ~/Areas/MySystem/Views/Web.config 转移到  ~/MySystem/Web.config 下可以。 但是如果在  ~/Areas/MySystem/Views/Web.config 下添加:

      <system.web>

        <authentication mode="Forms">
          <forms loginUrl="~/Login" timeout="2880" />
        </authentication>

    </system.web>

    则会报: 在应用程序级别之外使用注册为 allowDefinition='MachineToApplication' 的节是错误的。

    他妈的,这就是一个不成熟的坑爹玩意儿。

  • 相关阅读:
    Python常用模块学习
    如何在cmd下切换不同版本的Python
    Python3
    Python第二模块(文件和函数)
    Hibernate教程一览
    struts2框架一览
    Java正式day_04——嵌套循环
    AJAX
    JS+JQUERY
    Mybatis注意问题
  • 原文地址:https://www.cnblogs.com/newsea/p/3774538.html
Copyright © 2011-2022 走看看