我的程序在本机运行正常,但发布到服务器时,经常出现如下错误,刷新一下就好了,但进入网页后台一点错误都没有,前台出现错误时偶然的Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Controls_ContactBar.Page_Load(Object sender, EventArgs e) in e:\lq\ASPDOTNET05\ECSystem\WebUI\Controls\ContactBar.ascx.cs:19
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
前台和后台相比多了 cache,母板,和用户控件要是这些导致出错,本机测试也应该出现的,本机测试一点问题都没郁闷阿,各位高手帮忙了
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. Stack Trace:
[NullReferenceException: Object reference not set to an instance of an object.]
Controls_ContactBar.Page_Load(Object sender, EventArgs e) in e:\lq\ASPDOTNET05\ECSystem\WebUI\Controls\ContactBar.ascx.cs:19
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34
System.Web.UI.Control.OnLoad(EventArgs e) +99
System.Web.UI.Control.LoadRecursive() +47
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Control.LoadRecursive() +131
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
前台和后台相比多了 cache,母板,和用户控件要是这些导致出错,本机测试也应该出现的,本机测试一点问题都没郁闷阿,各位高手帮忙了
解决方案 »
- 如何删减FCKeditor控件上面的功能阿?
- asp.net 正则表达式 问题
- 求一个方法。。。关于seo的
- Dataview DataKeys 报错:索引超出范围!!高手请进!!!
- 关于音乐网的音乐连播页
- 有没有asp.net中开发activex控件的资料,还有发行数字证书的方法?
- 【虚心请教】什么是门户网站?它与普通网站有何不同?利用·NET能否完成这个项目?
- 高手帮忙Access读取ACCESS自动编号
- 为什么ASPX中使用的WEB用户控件不能在CODEBEHIND中自动产生类型定义?
- 救命!一个很好玩的问题
- jscript语言,怎么向Date()中传递参数?
- 这个语句应该怎么用inner join?
e:\lq\ASPDOTNET05\ECSystem\WebUI\Controls\ContactBar.ascx.cs:19
e:\lq\ASPDOTNET05\ECSystem\WebUI\Controls\ContactBar.ascx.cs:19这里的错误.
int ID = (int)HttpContext.Current.Cache["ID"];
HttpContext.Current.Cache["ID"]为null时就会引发,加个if过滤一下
1 web.config
2 数据内容
(2)查找一下关于IIS的进程回收,垃圾回收等内容。
(3)不用cache,改用静态类存贮,看看是否还会出现问题。总体上,怀疑cache被IIS回收或其它原因造成进程IIS重启后cache被清空。
if(HttpContext.Current.Cache["ID"]==null)
{
初始化cache
}即使在页面里cache为空,请求时也会被初始化啊Application_BeginRequest 不是执行每次请求前先执行的么?
if(HttpContext.Current.Cache["ID"]==null)
{
初始化cache
}即使在页面里cache为空,请求时也会被初始化啊Application_BeginRequest 不是执行每次请求前先执行的么?(1)加测试语句,看是否的确在请求之间执行,并输出cache值。特别是出错的时候要注意。
(2)如果以上没有问题,那么错误不在这个语句上。