Home  /  Questions  /  Question



50   0
Sep 05, 2015


Spark CustomPrincipal is null for some requests?

Hi,

In the Spark 4.5 Art solution, has anyone run into the problem where the CustomPrincipal properties are NULL for some requests?  I first noticed this with the ChangeAccount action method in the AuthController where the CurrentUser.Id property was null.  Interestingly GET requests it seems to be fine (see attached screenshots).

For example, 

// This results in a NULL user because the CurrentUser.Id property is null
// for the ChangeAccount action method in the AuthController.
var user = PeerReviewContext.Users.Single(CurrentUser.Id);

I did some testing and for GET requests System.Threading.Thread.CurrentPrincipal is CustomPrincipal is true, but it's false for POST requests.

I thought it might be something I had done to the solution so I deleted the local installation and unzipped it again from the source, but the issues persists.

Anyone else experiencing this, and better yet, do you know what the issue is?

Regards,
Mark
 





 1 comment
 
Anyone else experiencing this? --- Mark Erasmus  Sep 16, 2015



50   0
Sep 17, 2015
My fix for this was assigning  HttpContext.Current.User = customPrincipal; in the Application_PostAuthenticateRequest() method in the global.ascx, instead of assigning it to the current thread's principal.  Using the current thread's principal just wasn't a reliable approach since I was intermittently getting nulls back for the CurrentUser properties for identical request.  Obviously I had to update the CurrentUser class to use HttpContext.Current.User, rather than Thread.Current.Principal. 

0   0
9 days ago
Actually all user are using the same setting and they are facing lots of trouble also thus they cannot use this because some features  are not working properly due to that they are not able to maintain the webpages http://deletebrowsinghistory.net/ so my dear users don't be upset enjoy the internet world with this one.