Object reference not set to an instance of an object - Error for newly added property

Vote:
 

Hi All,

I have got unexpected error while creating a new Page in Epi-Server, in following way.

  1. I have created the PageType as  news with some properties.
  2. Created the Page from this  and it is working fine.
  3. After some time I have added new property called as PageIntrodcution in that and publish.
  4. It is working some days before and currently working fine for existing pages.
  5. But when try to create new page,  it show the NullReference error on this newly added property.

Full Error :

[NullReferenceException: Object reference not set to an instance of an object.]
   ASP._Page_Views_NewsList_Index_cshtml.Execute() in C:\Manpower\Manpower.Applications.Inside.Intranet\Manpower.Applications.InsideIntranet\Views\NewsList\Index.cshtml:50
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy() +252
   System.Web.Mvc.WebViewPage.ExecutePageHierarchy() +147
   System.Web.WebPages.StartPage.ExecutePageHierarchy() +88
   System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) +106
   System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) +374
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +89
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) +833
   System.Web.Mvc.ControllerActionInvoker.InvokeActionResultWithFilters(ControllerContext controllerContext, IList`1 filters, ActionResult actionResult) +81
   System.Web.Mvc.Async.<>c__DisplayClass21.b__1e(IAsyncResult asyncResult) +186
   System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeAction(IAsyncResult asyncResult) +38
   System.Web.Mvc.Controller.b__1d(IAsyncResult asyncResult, ExecuteCoreState innerState) +29
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
   System.Web.Mvc.Controller.EndExecuteCore(IAsyncResult asyncResult) +53
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +36
   System.Web.Mvc.Controller.EndExecute(IAsyncResult asyncResult) +38
   System.Web.Mvc.MvcHandler.b__5(IAsyncResult asyncResult, ProcessRequestState innerState) +44
   System.Web.Mvc.Async.WrappedAsyncVoid`1.CallEndDelegate(IAsyncResult asyncResult) +65
   System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) +38
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +399
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +137

Please help me.

Thanks

Abhishek

#179348
Edited, Jun 08, 2017 17:48
Vote:
 

To me, it looks like you are not checking the property for null when it is rendered in the view

#179352
Jun 08, 2017 19:28
Vote:
 

Hi Per,

Thanks fro reply!

Yes, I had put the check, but it still showing the error at the if end bracket.  BTW it is same as other properties which has no check ans these are working properly.

For quick fix, I have tried to change the property name , but no luck.

Please help me.

Thanks

Abhishek

#179353
Jun 08, 2017 19:40
Vote:
 

Hi,

One more thing, I have tried it to solve by asigning default value and that value get accepted , but still it throwing the Null refernce exception.

An exception of type 'System.NullReferenceException' occurred in App_Web_y4kh1w3k.dll but was not handled in user code

Additional information: Object reference not set to an instance of an object.

Any suggestions!

Thanks

Abhishek

#179354
Jun 08, 2017 19:50
Vote:
 

Hi,

Actually that error is not regarding to this one property only. I tried it commented out the line and it showing same error for other property and so on.

NOw I am really don't understand what goes wrong. 

I have doubt that ,  I have created one another page with same properties name. Is it affecting?

#179355
Jun 08, 2017 20:02
Vote:
 

Ah! Found the root cause.

Actualy in this page there is url property which  throwing exception while creating the page!

@Per, I  you were right! Need to chekc the null on view.

Thanks

Abhishek

#179381
Jun 09, 2017 10:50
Vote:
 

Glad you figured it out

#179383
Edited, Jun 09, 2017 10:52
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.