IIS7使Object引用未设置为对象错误的实例

时间:2011-08-08 17:07:22

标签: asp.net sql iis iis-7

我有一个使用.net 4.0框架的IIS7应用程序。应用程序池对应用程序的文件夹具有权限(读/写/执行),并具有(选择/读取/连接)数据库的权限。 IIS7接受aspx文件,一切似乎都很好,但是当我从服务器外部调用ti时,我收到404错误。

当我进入服务器并拨打http://localhost链接时,我收到此错误

    Server Error in '/Phonebook/PhoneBook' Application.
--------------------------------------------------------------------------------

Object reference not set to an instance of an object.  
Description: An unhanded 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.]
   PhoneBookApplication.DBUtils.Execute(SqlCommand command) +399
   PhoneBookApplication._Default.FillddlSearch() +156
   PhoneBookApplication._Default.Page_Load(Object sender, EventArgs e) +54
   System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +24
   System.Web.UI.Control.LoadRecursive() +70
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3047




--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.1 

如果我调用default-defaut.html文件,它可以正常工作,但如果我调用default-defaut.aspx则不行。但是在daufault页面设置中,aspx和html都在那里。

此外,它似乎与sql server有关,但我不明白在哪里调试

我不知道这是做什么的。有人可以帮忙吗?

2 个答案:

答案 0 :(得分:1)

方法DBUtils.Execute似乎有错误。你对page_load或page_load之前的任何事件有什么看法?

答案 1 :(得分:1)

错误告诉您问题的确切位置:

DBUtils类的第3行有一个错误:

PhoneBookApplication.DBUtils.Execute(SqlCommand command) +399

IIS不是问题。如果您收到404错误是因为您没有找到正确的URL。