首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > .NET > C# >

当前下上文中不存在名称“HttpContext”

2012-08-13 
当前上下文中不存在名称“HttpContext”C# codeprivate XmlDocument loadConfigDoc(XmlDocument cfgDoc){//

当前上下文中不存在名称“HttpContext”

C# code
        private XmlDocument loadConfigDoc(XmlDocument cfgDoc)        {            // load the config file               if (Convert.ToInt32(ConfigType) == Convert.ToInt32(ConfigFileType.AppConfig))            {                docName = ((Assembly.GetEntryAssembly()).GetName()).Name;                docName += ".exe.config";            }            else            {                docName = HttpContext.Current.Server.MapPath("web.config");//错误在这里            }            cfgDoc.Load(docName);            return cfgDoc;        }

我按System.Web.自动完成也没有HTTPcontext这个类!

[解决办法]
winform 里肯定为空,因为这个属性只有在网站里才会被加载。

热点排行