Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
Calling all developers! We invite you to provide your input on Feature Experimentation by completing this brief survey.
That's very strange. CustomerContext.Current is a static property and it should not be different between pages.
What do you have in PrincipalInfo.Current.Principal? If PrincipalInfo.Current.Principal.GetCustomerContact() returns null then it's likely because PrincipalInfo.Current.Principal is null or PrincipalInfo.Current.Principal.Identity is null
QuickSilver is using Owin/AspnetIdentity and those properties work perfectly. I suspect it's something in your configuration - so as usual - I would suggest you to contact our developer support service for further assistance
Hi Quan,
I have implmented the AspIdentity provider. However situation is same.
I am facing the issue on webapi calls .
PrincipalInfo.Current.Principal.GetCustomerContact() is always null.
Regards
Venkata Phani kumar R
Can you post your Startup.cs file here, if it does not contain any sensitive information?
This is a less known area and I've never seen this error, so I'm not sure I can spot anything. We should be able to say more if we have the entire solution which can reproduce the problem.
public class Startup
{
private readonly ILogger _logService = EPiServer.Logging.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
// For more information on configuring authentication,
// please visit http://world.episerver.com/documentation/Items/Developers-Guide/Episerver-CMS/9/Security/episerver-aspnetidentity/
private readonly IConnectionStringHandler _connectionStringHandler;
public Startup() : this(ServiceLocator.Current.GetInstance<IConnectionStringHandler>())
{
// Parameterless constructor required by OWIN.
}
public Startup(IConnectionStringHandler connectionStringHandler)
{
_connectionStringHandler = connectionStringHandler;
}
public void Configuration(IAppBuilder app)
{
// Add CMS integration for ASP.NET Identity
app.AddCmsAspNetIdentity<SiteUser>(new ApplicationOptions
{
ConnectionStringName = _connectionStringHandler.Commerce.Name
});
// Use cookie authentication
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/User"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity =
SecurityStampValidator.OnValidateIdentity<ApplicationUserManager<SiteUser>,SiteUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => manager.GenerateUserIdentityAsync(user))
}
});
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
// Enables the application to temporarily store user information when they are verifying the second factor in the two-factor authentication process.
app.UseTwoFactorSignInCookie(DefaultAuthenticationTypes.TwoFactorCookie, TimeSpan.FromMinutes(5));
// Enables the application to remember the second login verification factor such as phone or email.
// Once you check this option, your second step of verification during the login process will be remembered on the device where you logged in from.
// This is similar to the RememberMe option when you log in.
app.UseTwoFactorRememberBrowserCookie(DefaultAuthenticationTypes.TwoFactorRememberBrowserCookie);
}
}
Hi All,
I have an issue with CustomerContext.Current . In CMS pages CustomerContext.Current is giving the right detial of the login person. Where as on Commerce pages eg: Product Details pages ,CustomerContext.Current is Null.
PrincipalInfo.Current.Principal.GetCustomerContact() is also null.
if (System.Web.HttpContext.Current.Request.LogonUserIdentity != null &&
System.Web.HttpContext.Current.Request.LogonUserIdentity.IsAuthenticated) is true.
I am using form authentication . Owin Components are instaaled to use the service api features.
Can some one suggest me the instructions to trouble shoot this issue.
Commerce version is 10.4.2
Regargds
Venkata Phani Kumar R