The issue was AuthenticationContext.HttpContext.User object is Null after SharePointContextProvider.CheckRedirectionStatus call inside OnAuthentication() method of custom ActionFilterAttribute of a provider hosted app.
Reason for this error was that the app was not registered in the dev server. After installing the app using AppRegNew.aspx this error was solved.
public void OnAuthentication(AuthenticationContext filterContext) { if (filterContext == null) { throw new ArgumentNullException("filterContext"); } bool ok = false; Uri redirectUrl; switch (SharePointContextProvider.CheckRedirectionStatus(filterContext.HttpContext, out redirectUrl)) { case RedirectionStatus.Ok: ok = true; break; case RedirectionStatus.ShouldRedirect: filterContext.Result = new RedirectResult(redirectUrl.AbsoluteUri); break; case RedirectionStatus.CanNotRedirect: filterContext.Result = new ViewResult { ViewName = "Error" }; break; } if (ok) { filterContext.Principal = filterContext.HttpContext.User;
Reason for this error was that the app was not registered in the dev server. After installing the app using AppRegNew.aspx this error was solved.
No comments:
Post a Comment