如环境:
网站A
    web.config
    虚拟目录B
        web.config
-------------------------------
如上,因为我的网站是用ASP.NET AJAX写的
这个时候就会在web.config里面添加很多关于AJAX的配置
而我的虚拟目录则是正常的网站,没有用AJAX这时虚拟目录就出错了
提示:
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
没有引用到这些东西
后来我把那几个DLL考进去就OK了但问题我下面有N++个虚拟目录
难道我要一个个的考进去吗
有什么办法可以让虚拟目录下的web.config访问到网站下的web.config呢?谢谢

解决方案 »

  1.   

    加上<remove ...>就行了
      

  2.   

    不remove的话,只能加这些DLL,或将虚拟目录移走,变成独立的网站
      

  3.   

    remove
    具体怎么配置在我的网站的web.config
    还是虚拟目录的web.config
    谢谢
      

  4.   

      以下计算机配置文件代码声明   <sampleSection>   这一节。   
        
      <!--   Machine.config   file.   -->   
      <configuration>   
            <configSections>   
                  <section   name="sampleSection"   
                                    type="System.Configuration.SingleTagSectionHandler"   />   
            </configSections>   
            <sampleSection   setting1="Value1"   setting2="value   two"     
                                          setting3="third   value"   />   
      </configuration>   
      下面的应用程序配置文件代码移除   <sampleSection>   节。移除之后,应用程序将无法检索   <sampleSection>   中的设置。   
        
      <!--   Application   configuration   file.   -->   
      <configuration>   
            <configSections>   
                  <remove   name="sampleSection"/>   
            </configSections>   
      </configuration>   
    ------------------------------------------
    我看了用法
    如果 是这样的话,那不是挂了,要写一大把的remove
    能不能直接生明不要去访问他的上级配置呢谢谢
      

  5.   

    总结:
    1.站点要.net2.0的环境
    2.根目录下的web.config 用<location path="." allowOverride="true" inheritInChildApplications="false"></location>来限止web.config的一些继承
    -----------------------------------------------------------------------------
    这是我网上找到的,不知是否可行
      

  6.   

    <?xml version="1.0" encoding="UTF-8"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
        <configSections>
          ...
        </configSections>
      <location path="." inheritInChildApplications="false">
       
             Put your configuration code here.........  </location>
    </configuration>
      

  7.   

    RE:不行
    inheritInChildApplications="false"
    只对system.web system.webServer 有效
    但是对configSections 无效
    但是我的configSections里面有system.web.extensions虚拟目录还是会报错
    能不能让整个web.config都不向下继承呢谢谢
      

  8.   

    建议用datatable一次性把数据全取出来,通过遍历datatable(操作内存)来操作 
    发一个我自己写的给你参考一下 Model 
    using System;
    namespace WZMM.Model
    {
        /// <summary>
        /// 实体类ClassModel 。(属性说明自动提取数据库字段的描述信息)
        /// </summary>
        public class ClassModel
        {
            public ClassModel()
            { }
            #region Model
            private int _id;
            private int _classid;
            private string _name;
            private bool _isdelete;
            private bool _state;
        
                 public int id
            {
                set { _id = value; }
                get { return _id; }
            }
      
            public int classid
            {
                set { _classid = value; }
                get { return _classid; }
            }        public string name
            {
                set { _name = value; }
                get { return _name; }
            }        public bool isdelete
            {
                set { _isdelete = value; }
                get { return _isdelete; }
            }        public bool state
            {
                set {
                    _state = value;
                    
                    }
                get { return _state; }
            }
            #endregion Model
        }
    }        public static List<ClassModel> Select()
            {
                DataTable dt = GetTable();
                List<ClassModel> list = new List<ClassModel>();
                ClassModel model = new ClassModel();
                model.id = 0;
                model.name = "===请选择类别===";
                list.Add(model);
                OrderSelect(dt, list, 0, "|-");
                dt.Clear();
                return list;
            }        static DataTable GetTable()
            {
                DataTable dt = new DataTable();
                DataSet ds = new DataSet();
                Database.RunProc("CLASS_Select", out ds);
                dt = ds.Tables[0];
                return dt;
            }        static void OrderSelect(DataTable dt, List<ClassModel> list, int classid, string strTop)
            {
                DataRow[] rows = dt.Select("classid=" + classid);
                for (int i = 0; i < rows.Length; i++)
                {
                    ClassModel model = new ClassModel();
                    model.id = int.Parse(rows[i]["id"].ToString());
                    model.name = strTop + rows[i]["name"].ToString();
                    list.Add(model);
                    string str = "  " + strTop;
                    int id = int.Parse(rows[i]["id"].ToString());
                    OrderSelect(dt, list, id, str);
                }
            }表: 
    CREATE TABLE [dbo].[classes] ( 
    [id] [int] IDENTITY (1, 1) NOT NULL 0, 
    [classid] [int] NOT NULL 0, 
    [name] [varchar] (50) COLLATE Chinese_PRC_CI_AS NOT NULL '', 
    [isdelete] [bit] NOT NULL 0, 
    [state] [bit] NOT NULL 1 
    ) ON [PRIMARY] 
    GO 
      

  9.   

    web.config是继承的,虚拟目录的webconfig会自动继承站点的config
      

  10.   


    把你除了configSecton之外的东西都放到<location path="." inheritInChildApplications="false">
     
           
      </location> 
    里面去如<?xml version="1.0" encoding="UTF-8"?>
    <configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
        <configSections>
          ...
        </configSections>
      <location path="." inheritInChildApplications="false">
     
            Put your configuration code here.........  </location>
    </configuration>就可以了,说了几遍,你还没看明白...
      

  11.   

    有什么办法可以让虚拟目录下的web.config访问到网站下的web.config呢? 
    ==
    不知道楼上的是否可行,默认情况下子目录的web.config的配置会覆盖上级目录的web.config,当然可以把子目录的web.config删除..
      

  12.   

    jzywh的方法不错,不用动子目录的配置了。