Reputation: 73
It keeps giving me error ("Object reference not set to an object instance") while running SetAuthCookie. The line that goes wrong is this:
System.Web.Security.FormsAuthentication.SetAuthCookie(TokenManager.GenerateToken(utente.IDUtente, true), true);
where TokenManager.GenerateToken is our function to generate a token (string)
I'm sure it's not the GenerateToken that creates the error because I assigned the result of the function to a variable and then used the variable inside the SetAuthToken and the error comes from SetAuthToken
var newToken = TokenManager.GenerateToken(utente.IDUtente, true);
System.Web.Security.FormsAuthentication.SetAuthCookie(newToken, true);
I tried that too, but it still gives the same error...
System.Web.Security.FormsAuthentication.SetAuthCookie("foo", false);
Since they deleted the last question I asked, I specify that SetAuthToken is external code, therefore not mine, and therefore I don't need to resolve the "Object reference not set to an object instance", but understand why the function generates this error.
Some advice?
Upvotes: 2
Views: 67