asp.net网页,服务端代码一加入以下代码。
string sno = Request.QueryString["sno"].ToString();
在本地运行正常。
发布iis7.0就报错,请大咖们赐教。。。
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.
string sno = Request.QueryString["sno"].ToString();
这句代码,当Request.QueryString["sno"]为null时,对空对象使用.ToString();
就会报错误: Object reference not set to an instance of an object
这是NET里面的经典错误了,都是使用对象属性或方法之前没有判断对象是否为空造成的。