NullReferenceException when running published website in IIS

大憨熊 提交于 2019-12-04 05:47:04

问题


I have a website that I published before adding it in IIS. After that I set the published website as the default website in IIS.

I got an error that the "Object reference is not set to the instance of an object" when I inserted values through form. There is no issues when the website is running in IIS without publishing. The error occurs when values are inserted using datagrid.

The error messages is as follows:

Server Error in '/' Application.

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.]
Admin_MasterEntries.gvwMileStoneM_RowCommand(Object sender, GridViewCommandEventArgs e) +447 System.Web.UI.WebControls.GridView.OnRowCommand(GridViewCommandEventArgs e) +105
System.Web.UI.WebControls.GridView.HandleEvent(EventArgs e, Boolean causesValidation, String validationGroup) +76
System.Web.UI.WebControls.GridView.OnBubbleEvent(Object source, EventArgs e) +95
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.GridViewRow.OnBubbleEvent(Object source, EventArgs e) +117
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +35
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +115
System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) +163
System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +7
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +11 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +174
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5102

If any one knows please help me. Thank you.


回答1:


That exception is caused by an object not being instantiated. Open the project and attach a debugger to the IIS process. A web service which is consuming the ASP.NET page is throwing the exception.




回答2:


Try this:

  1. Click your site in IIS
  2. Open Pages and Controls section
  3. Find ViewState group and check if ViewState is enabled.

Such solution helped me to solve null reference exception problem after publish.



来源:https://stackoverflow.com/questions/1518396/nullreferenceexception-when-running-published-website-in-iis

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!