NullReferenceException in FederatedAuthentication.GetHttpCon

Posted by Community Admin on 04-Aug-2018 19:17

NullReferenceException in FederatedAuthentication.GetHttpContextModule() when calling SecurityManager.AuthenticateUser

All Replies

Posted by Community Admin on 26-Jun-2014 00:00

I thought I'd post this because it may be useful to others.

 

I created a custom MVC login widget. Inside my controller, I make the following call:

var userLoggingReason = SecurityManager.AuthenticateUser(userManager.Provider.Name, username, password, false);

This call fails with a NullReferenceException (stack trace below). After some investigating, it turns out that the NullReferenceException is because HttpContext.Current.ApplicationInstance is null.

 I found the following in www.sitefinity.com/.../internal-hotfix-builds which I think will fix the problem, but I haven't upgraded to verify:

 

Sitefinity 7.0.5110 Version Notes
MVC context does not copy ApplicationInstance and Cookies

 

Stack Trace: 

[NullReferenceException: Object reference not set to an instance of an object.]
Microsoft.IdentityModel.Web.FederatedAuthentication.GetHttpContextModule() +83
Microsoft.IdentityModel.Web.FederatedAuthentication.GetHttpModule() +200
Microsoft.IdentityModel.Web.FederatedAuthentication.get_SessionAuthenticationModule() +33
Telerik.Sitefinity.Security.Claims.SitefinityClaimsAuthenticationModule.AuthenticatePrincipalWithCurrentToken(IClaimsPrincipal principal, Boolean persistent) +177
Telerik.Sitefinity.Security.SecurityManager.AuthenticateUser(User user, UserManager manager, Boolean persistent) +515
Telerik.Sitefinity.Security.SecurityManager.AuthenticateUser(String membershipProviderName, String userName, String password, Boolean persistent, User& user) +279
Telerik.Sitefinity.Security.SecurityManager.AuthenticateUser(String membershipProviderName, String userName, String password, Boolean persistent) +57
SitefinityWebApp.Mvc.Controllers.LoginController.Login(String username, String password) in c:\Users\Bo\Plastic Workspaces\<deleted>\Mvc\Controllers\LoginController.cs:77
SitefinityWebApp.Mvc.Controllers.LoginController.Index(LoginViewModel loginViewModel) in c:\Users\Bo\Plastic Workspaces\<deleted>\Mvc\Controllers\LoginController.cs:62
lambda_method(Closure , ControllerBase , Object[] ) +159
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +211
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.<>c__DisplayClass13.<InvokeActionMethodWithFilters>b__10() +55
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation) +253
System.Web.Mvc.<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12() +21
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList`1 filters, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +191
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +324
Telerik.Sitefinity.Mvc.ControllerWrapper.Execute() +148

Posted by Community Admin on 22-Sep-2015 00:00

I'm still seeing this issue.

 Has anyone confirmed whether this is fixed yet? Or if there is a workaround?

Posted by Community Admin on 09-Mar-2016 00:00

i was also waiting for the update!

Posted by Community Admin on 14-Mar-2016 00:00

Hello Bo,

Testing the scenario to get the ApplicationInstance - user identity on Sitefinity 8.2 in controller seems working fine (screenshot).

Can you please provide more information about the code used and the scenario you want to achieve?

Regards,
Svetoslav Manchev
Telerik

 
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
 

This thread is closed