OfficeDev / hands-on-labs

This repo represents the content for the Coding Challenges, typically used for Microsoft Developer Events (i.e. //build)
25 stars 25 forks source link

O3653-7 Exception thrown #101

Closed lucas66 closed 4 years ago

lucas66 commented 8 years ago

Module Number: O3653-7 Module Title: Microsoft Graph for OneNote Services Path of file:

Details of issue

I get a null object exception thrown before I log into MS to test the app.

Stack trace System.NullReferenceException was unhandled by user code HResult=-2147467261 Message=Object reference not set to an instance of an object. Source=App_Web_zn5r2iyi StackTrace: at ASP._Page_Views_SharedLayout_cshtml.Execute() in C:\Dev\OneNoteDev2\OneNoteDev2\Views\Shared_Layout.cshtml:line 33 at System.Web.WebPages.WebPageBase.ExecutePageHierarchy() at System.Web.Mvc.WebViewPage.ExecutePageHierarchy() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer) at System.Web.WebPages.WebPageBase.<>cDisplayClass3.b__2(TextWriter writer) at System.Web.WebPages.HelperResult.WriteTo(TextWriter writer) at System.Web.WebPages.WebPageExecutingBase.WriteTo(TextWriter writer, HelperResult content) at System.Web.WebPages.WebPageBase.Write(HelperResult result) at System.Web.WebPages.WebPageBase.RenderSurrounding(String partialViewName, Action1 body) at System.Web.WebPages.WebPageBase.PopContext() at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage) at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance) at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer) at System.Web.Mvc.ViewResultBase.ExecuteResult(ControllerContext context) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResult(ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) at System.Web.Mvc.ControllerActionInvoker.InvokeActionResultFilterRecursive(IList`1 filters, Int32 filterIndex, ResultExecutingContext preContext, ControllerContext controllerContext, ActionResult actionResult) InnerException:

jthake commented 8 years ago

is this something to do with the Microsoft Graph SDK that is being used for these labs? seeing lots of activities in changes here? @garethj-msft

garethj-msft commented 8 years ago

Graph SDK isn't being used for OneNote cos it's not 1.0

DianeD commented 8 years ago

unable to repro error. Assigning to @vsharma77 to retest too.

DianeD commented 8 years ago

@lucas66 can you share your project?

lucas66 commented 8 years ago

This might be related to issue #102. All Graph AAD Auth v1 starter project templates are throwing this error for me. @DianeD how would you like me to share?

DianeD commented 8 years ago

@lucas66 can you send a link to a share or put the project folder here? https://github.com/OfficeDev/office-docs/tree/master/O3653/O3653-7%20Deep%20Dive%20into%20the%20Office%20365%20APIs%20for%20OneNote%20services/Labs/Completed

lucas66 commented 8 years ago

@DianeD my project is here: https://github.com/OfficeDev/office-docs/tree/master/O3653/O3653-7%20Deep%20Dive%20into%20the%20Office%20365%20APIs%20for%20OneNote%20services/Labs/Completed/OneNoteDev-lucas66

It is a raw project, you'll have to build it to restore the nuget packages then deploy it.

DianeD commented 8 years ago

Thanks @lucas66. Is this just the empty project created from the template? I don't see any OneNote content. I was able to log in okay with my test credentials.

DianeD commented 8 years ago

@lucas66 can you try this change from @jasonjoh since I can't repro?

...this may be an issue where OpenID says you are authenticated but actually has no identity. Can you try replacing this line in _Layout.cshtml:

@if (Request.IsAuthenticated)

With:

@if (Request.IsAuthenticated && null != System.Security.Claims.ClaimsPrincipal.Current && null != System.Security.Claims.ClaimsPrincipal.Current.FindFirst("http://schemas.xmlsoap.org/ws/2005/05/identity/claims/upn"))

lucas66 commented 8 years ago

@DianeD The fix from @jasonjoh worked and got me past the initial error. Should replacing the line in _Layout.cshtml be a step in the lab.md?

DianeD commented 8 years ago

Great! If we don't have time to update the template, then yes. @jthake @keyur32

jthake commented 8 years ago

I have no idea how to change the template. @jasonjoh do you have time to change it and send it to me so I can update the Master VM? be a shame to have to add this to ALL labs as an additional step.

jasonjoh commented 8 years ago

I just got in. I can send you a new _Layout.cshtml file that you would just need to replace inside the template zip files. I'll email that to you shortly.

jasonjoh commented 8 years ago

Ok, I wasn't able to drop them into the zips, so I just created new zips and put them on my OneDrive for Biz. Sent you a link Jeremy.