本文介绍了Global.asax变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好, 我试图连接到Xml数据库,我想在Application_Start中加载Xml 文档。所以xml只加载一次,然后按照要求多次查询,这应该是有效的方式来连接到数据库afaik,但是我可以'在中访问xml对象我的aspx文件中出现此错误dbxml在当前上下文中不存在: <%@应用程序语言= QUOT; C#" %> < script runat =" server"> Xmldb dbxml; void Application_Start(object sender,EventArgs e) { dbxml = new Xmldb(Server.MapPath("〜")); //在应用程序启动时运行的代码 } ... 我虽然在global.asax文件中声明的任何变量应该是 可用于任何其他aspx页面,如何我可以访问变量吗? 在此先感谢 Yehia A.SalamHello,I was trying to connect to an Xml database, and I thought of loading the XmlDocument in "Application_Start" so that the xml is loaded only once and thenqueried later as many times as requested, this should the efficient way ofconnecting to the database afaik, however I can''t access the xml object inmy aspx files with this error "dbxml does not exist in current context":<%@ Application Language="C#" %><script runat="server">Xmldb dbxml;void Application_Start(object sender, EventArgs e){dbxml = new Xmldb(Server.MapPath("~"));// Code that runs on application startup}...I though that any variable declared in the global.asax files should beavailable to any other aspx page, how could I access the variable?Thanks In AdvanceYehia A.Salam推荐答案 这篇关于Global.asax变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 07-31 10:21