Passing Autumn

The same 3 years, and some people from students to as the MVP, and I was in place, then the code to show off the autumn wind, a little sad, a little cool!

公告信息
Content is very powerful ~ ~ ~ ~ ~ ~ Do not look outside the invasion not as sharp and brother, I felt kind of sense of loss ~ ~ ~

HttpContext.Current.Request.UserHostAddress 未将对象引用到对象实例

小小记录下某点记忆:

这是前两天我又偶遇的问题,花了我近一个多小时,才意识到这段到代码。

HttpContext.Current.Request.UserHostAddress,这功能就不多解释了,Web里取用户真实IP的。

事故就发生在,我把某个函数抽了出来,然后除了原先的调用,还供另一个定时线程调用。


在本机测试时,本机直接找某个页面,调用了函数,一切正常。

然后就上传到服务器,结果就是不停的抛出未将对象引用到对象实例的错误。

于是本机又测试(对报错的函数进行的),又正常,步步调试也没啥问题,数据库也正常进入。

最怕的事情来了,本机无法查错,服务器又错误,心急啊。

对这错误,我也算遇到千千万万回来了,不停的检测代码哪里有问题。

于是开始,写Log输出,缩小代码断,不断的给某些正常的函数加try。

一直折腾了一个多小时,才发现了HttpContext.Current.Request.UserHostAddress这代码。

突然意识到,在线程里,HttpContext.Current是个Null对象,引发的错误。

然后的事,就没啥事了。。。。
Autumn Park is QBlog the official site, created by the passing autumn, based on the framework data layers developed cyqdata support multi-user, multi-language, multi-database (access, mssql, oracle), directory level url and other powerful blog system
新浪微博粉丝精灵,刷粉丝、刷评论、刷转发、企业商家微博营销必备工具"

2013/3/12 19:22:02 | Other | |

  • 发表评论